CSS Webkit 过渡 - 淡出比淡入慢

18

这是我的代码:

.box{
    background:#FFF;
    -webkit-transition: background 0.5s;
}

.box:hover{
    background:#000;
}

但是这样会同时影响onmouseoveronmouseout两个事件,有没有办法控制它们呢?类似这样:

-wekbkit-transition-IN: background 1s;
-webkit-transition-OUT: background 10s;
2个回答

31

只需在 ::after 伪元素中重新定义您的过渡效果。

.box{
    background: white;
    -webkit-transition: background 5s;
}
.box:hover{
    background: olive;
    -webkit-transition: background 1s;
}

请查看我的http://jsfiddle.net/DoubleYo/nY8U8/


0

可以使用动画(目前仅在Webkit中可用),或使用JS添加和删除属性,它们仍将进行动画处理。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接