JavaScript无缝滚动效果的实例代码
废话不多说了,直接给大家贴代码了,具体代码如下所示:
Document *{ padding:0; margin:0; } .box{ width:600px; height:200px; margin:60pxauto; overflow:hidden; position:relative; } ul{ list-style-type:none; width:2000px; position:absolute; top:0; left:0; } li{ float:left; } varbox=document.getElementById("box"); vargun=document.getElementById("gun"); function$(i){ returndocument.getElementsByTagName("img")[i]; } varnum=0; all(); functionall(){ varshi=setInterval(fun,5); gun.onmouseover=function(){ clearInterval(shi); } gun.onmouseout=function(){ all(); } functionfun(){ if(num<=-1200){ num=0; }else{ gun.style.left=num+"px"; num--; } } }