Google Chrome 将 webkit 错误修复添加到版本 27.0.1453.110 m
此 WebKit 错误已修复:http ://trac.webkit.org/changeset/138632
可以为伪:before
元素和设置动画:after
,这里有几个用于为伪元素设置动画的示例:before
和:after
。
这是对上面示例的修改,并进行了一些编辑,使其动画进出更加流畅,而没有悬停时的模拟mouseleave
/mouseout
延迟:
http://jsfiddle.net/MxTvw/234/
尝试在第二个伪类规则中添加#foo
带有分组:hover
伪类的主选择器。:hover
还要添加transition
属性,而不仅仅是供应商特定的前缀属性transition
:
#foo:after{
display: block;
content: '';
width: 200px;
height: 200px;
background: red;
-webkit-transition: all .4s ease-in-out;
-moz-transition: all .4s ease-in-out;
-o-transition: all .4s ease-in-out;
transition: all .4s ease-in-out;
}
#foo,
#foo:hover:after,
#foo:hover:before{
width: 250px;
height: 250px;
}
请注意,任何伪元素(如:before
and ):after
都应使用双冒号语法::before
和::after
. 此示例使用叠加层background-color
和background-image
悬停来模拟淡入和淡出:
http://jsfiddle.net/MxTvw/233/
此示例模拟悬停时的旋转动画:
http://jsfiddle.net/Jm54S/28/
当然,我们可以使用 css3 标准,::before
并且::after
.
这适用于最新的 Firefox、Chrome、Safari、Opera 18+、IE10、IE11(IE9 及以下不支持 css3 过渡或动画。)