前端动画的几种实现方法
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()

浙公网安备 33010602011771号