CSS3淡入内容之前/之后

Chr*_*ris 1 css css3 css-transitions

我有以下悬停效果,我现在如何让这个淡入淡出?

HTML

<article>
    hello world
</article>
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

Cha*_*had 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;
}
Run Code Online (Sandbox Code Playgroud)