我正在做一个带有背景转换的CSS animation
,我想要一个不同的背景,用于:悬停。但是它不起作用:当我将光标悬停在div上时,动画仍然在播放,但是没有考虑悬停状态。
当我移除动画时,它工作得很完美。
你有什么想法吗?
谢谢
.loaderGif{
width: 465px;
height: 465px;
background: url('../images/loader01.png');
background-size: cover;
-webkit-animation: animLoader 4s infinite;
animation: animLoader 4s infinite;}
@-webkit-keyframes animLoader {
0% { background: url('../images/loader01.png'); }
50% { background: url('../images/loader02.png'); }
100% { background: url('../images/loader01.png'); }
}
.loaderGif:hover{
background: url('../images/loaderBlack.gif');
}
发布于 2015-02-12 12:20:08
动画中的CSS声明在动画期间覆盖其他声明:
"CSS动画会影响计算出的属性值。在动画执行期间,属性的计算值由动画控制。这将覆盖在普通样式系统中指定的值。动画覆盖所有正常规则,但被!重要规则覆盖。“- http://www.w3.org/TR/css3-animations/。
一旦动画完成,.loaderGif:hover将是活动的,不过万一它永远不会激活,因为动画是无限的。
若要解决问题,请将代码更改为
.loaderGif:hover{
-webkit-animation: none;
animation: none;
background: url('../images/loaderBlack.gif');
}
https://stackoverflow.com/questions/28486454
复制