不是轮播,是平滑滚动,已经修正问题。做了一个图片平滑滚动,发现这样性能有问题,很吃cpu。请问可以怎么优化?<body><div class="main"> <ul id="slide"> <li><img src="./images/1.jpg" width="100%" height="auto"/></li> <li><img src="./images/2.jpg" width="100%" height="auto"/></li> <li><img src="./images/3.jpg" width="100%" height="auto"/></li> <li><img src="./images/4.jpg" width="100%" height="auto"/></li> <li><img src="./images/1.jpg" width="100%" height="auto"/></li> </ul></div><script type="text/javascript">var slide = document.getElementById("slide");var scroll_time = null;var slide_left = 0;scroll_time = setInterval(autoPlay,10);function autoPlay(){ slide_left--; slide.style.left = slide_left + "px"; if(slide_left <= -2400){ slide_left = 0; }}slide.onmouseover = function(){ clearInterval(scroll_time);}slide.onmouseout = function(){ scroll_time = setInterval(autoPlay,10);}</script></body>
添加回答
举报
0/150
提交
取消