前端动画的几种实现方法

1. CSS的transition

2. CSS的animation

3. jQuery的animate

4. 原生js的setInterval

    let margLeft = 0
      let timer

      function autoPlay() {
        timer = setInterval(() => {
          margLeft -= 5
          if (margLeft == -1600) {
            // clearInterval(timer) //可以在内部使用
            margLeft = 0
          }
          $('ul').css('marginLeft', margLeft)
        }, 13.33); // 时间的选择以屏幕刷新率为宜
      }

      autoPlay()

 

posted @ 2021-01-25 11:43  潘思远  阅读(84)  评论(0)    收藏  举报