代码: 复制代码 代码如下: 无标题文档 <BR>*{ margin:0; padding:0;} <BR>#imgMove{ height:205px; width:624px; border:#000 1px solid; position:relative; margin:200px auto;overflow:hidden;} <BR>#imgMove ul{ height:205px;position:absolute; left:0; overflow:hidden;} <BR>#imgMove li{ list-style:none; float:left; height:205px; width:156px; margin:0;} <BR>a img,img{ border:none;} <BR>span{ z-index:999;height:68px; width:68px; display:none;position:absolute; cursor:pointer;} <BR>#moveLeft{left:0; top:68px; } <BR>#moveRight{right:-10px; top:68px;} <BR> <BR>window.onload=function(){ <BR>var oDiv=document.getElementById('imgMove'); <BR>var oUl=oDiv.getElementsByTagName('ul')[0]; <BR>var oli=oUl.getElementsByTagName('li'); <BR>var liSpeed=1; <BR>var ospan=oDiv.getElementsByTagName('span'); <BR>var rightmove=document.getElementById('moveRight'); <BR>var leftmove=document.getElementById('moveLeft'); <BR>function show(){ <BR>ospan[0].style.display="block"; <BR>ospan[1].style.display="block"; <BR>} <BR>oUl.onmouseover=function (){ <BR>show(); <BR>} <BR>oUl.onmouseout=function(){ <BR>ospan[0].style.display="none"; <BR>ospan[1].style.display="none"; <BR>} <BR>ospan[0].onmouseover=function(){ <BR>liSpeed=1; <BR>show();/*加这个函数是为了去除向左向右的图片闪动*/ <BR>} <BR>ospan[1].onmouseover=function(){ <BR>liSpeed=-1; <BR>show();/*加这个函数是为了去除向左向右的图片闪动*/ <BR>} <br><br>oUl.style.width=oli[0].offsetWidth*oli.length+'px';; <BR>setInterval(function(){ <BR>oUl.style.left=oUl.offsetLeft-liSpeed+'px'; <BR>if(oUl.offsetLeft<-oUl.offsetWidth/2){ <BR>oUl.style.left=0; <BR>} <BR>else if(oUl.offsetLeft>0) <BR>{ <BR>oUl.style.left=-oUl.offsetWidth/2+'px'; <BR>} <BR>},30) <BR>} <BR>