数秒間続くいくつかの要素のアニメーションがあります。それらのいずれかにカーソルを合わせると、CSS3 アニメーションが一時停止して何かを実行し、ホバーが外れたときにアニメーションを続行するようにします。
CSS3 アニメーションが発生していることを示すフィドルの簡単な例を次に示します。3 番目のバー (class .test を使用) にカーソルを合わせると、CSS がオーバーライドされます。
@keyframes animation {
from { width: 0;}
to {width: 200px;}
}
@-webkit-keyframes animation {
from { width: 0;}
to {width: 100%;}
}
div {
animation: animation 3s;
-webkit-animation: animation 3s;
display:block;
height:50px;
background:red;
margin-bottom:20px;
}
.change {width: 50%;}
$('.test').hover( function() {
$(this).toggleClass('change');
});
これを行う方法はありますか?