且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

循环功能,动画CSS旋转

更新时间:2021-12-23 04:45:24

如果要使用CSS制作动画,为什么不使用纯CSS? 您可以将animation属性包装在Class中,然后在JS中切换该类.

If you're animating with css why not using pure CSS? You can wrap the animation property in a Class and toggle that class in JS.

div {
  -webkit-animation:anim 2s ease infinite;
}
@-webkit-keyframes anim 
{
  0 {-webkit-transform:rotate(0deg);}
  50% {-webkit-transform:rotate(1deg);}
  100% {-webkit-transform:rotate(0deg);}
}

更新了小提琴