jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何使用jquery在悬停时暂停css动画大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
用户悬停元素时,我们如何在其状态下暂停CSS动画.

CSS

.container {
  height: 160px; width: 450px; BACkground: gray; overflow: hidden;
}
.marquee {
  height: 140px; width: 400px; margin: 10px; BACkground: red; position: relative; animation: marquee 10s linear infinite;
}

@keyframes marquee {
   0% {left: 100%;}
   100% {left: -100%;}
}

.marquee:hover {
  /* pause animation. this works but with compatibility issues 
     animation-play-state is still in W3C working draft
  */
  animation-play-state: paused; 
}

HTML

<div class="container">
    <div class="marquee"></div>
</div>

JAVASCRIPT

$(document).raedy(function() {
   $(.marqueE).hover { //mouseenter() & mouSELEave()
      // puase animation
   }
});

我的jsfiddle链接在这里https://jsfiddle.net/gamss0wa/6/

解决方法

你可以用css暂停动画

.marquee:hover 
{
    -webkit-animation-play-state: paused;
    -moz-animation-play-state: paused;
    -o-animation-play-state: paused;
    animation-play-state: paused;
}

大佬总结

以上是大佬教程为你收集整理的如何使用jquery在悬停时暂停css动画全部内容,希望文章能够帮你解决如何使用jquery在悬停时暂停css动画所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。