1

我有以下悬停效果,我现在如何使它淡入淡出?

HTML

<article>
    hello world
</article>

CSS

article
{
    position: relative;
    float: left;
    margin: 0 16px 16px 0;
    padding: 10px;
    width: 228px;
    height: 228px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box; 
    box-sizing: border-box; 
    overflow: hidden; 
    background: green;
}

article:hover:after
{ 
    content: ''; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 322px; 
    height: 322px; 
    background: #fff;
    -webkit-transform: translate(-161px, -161px) rotate(135deg); 
    -moz-transform: translate(-161px, -161px) rotate(135deg); 
    transform: matrix(-161px, -161px) rotate(135deg); 
    opacity: 0.5; 
    -webkit-transition: opacity 1s ease-in-out; 
    -moz-transition: opacity 1s ease-in-out; 
    transition: opacity 1s ease-in-out;
}

JSFiddle

4

1 回答 1

5

如果您没有起点和终点,您的元素将不会变形或移动。你要做的是article:after先设置你的,然后当你将鼠标悬停在文章上时设置它应该是什么。像这样的东西:http: //jsfiddle.net/E8dNe/1/

article:after { 
    content: '×'; 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 322px; 
    height: 322px; 
    background: #fff;
    opacity: 0; 
    -webkit-transition: 1s all ease-in-out; 
}

article:hover:after {    
    -webkit-transform: translate(-161px, -161px) rotate(135deg); 
    opacity: .5;
}
于 2013-07-17T15:52:36.850 回答