Ger*_*the 8 css webkit css3 css-transitions
我尝试使用webkit-animation和@ -webkit-keyframes制作动画.我有一个带有子div的动画div.
当我的鼠标在孩子身上时,我会停止父母的webkit动画.
任何例子?
谢谢
met*_*ion 22
遗憾的是CSS中没有父选择器,请参见此处.您将不得不使用一些javascript来选择父级并告诉它暂停.
CSS中的暂停声明如下:
-webkit-animation-play-state: paused | running;
Run Code Online (Sandbox Code Playgroud)
javascript(在本例中为jQuery)看起来像这样:
$(".child").hover(
function(){
$(this).parent().css("-webkit-animation-play-state", "paused");
},
function(){
$(this).parent().css("-webkit-animation-play-state", "running");
});
Run Code Online (Sandbox Code Playgroud)
在这里观看现场演示:
小智 8
如果您使用更复杂的标签,您可以在没有Javascript的情况下实现此目的.我用过
.parent:hover .child { -webkit-animation-play-state: paused; },它完美无缺.