日期:2014-05-16 浏览次数:20337 次
<html> <head> <style type="text/css"> #top{width:900px;overflow:hidden;} #con{height:340px;width:900px;width:2700px;} #con div.demo{width:900px;height:340px;background:#ff99ff;float:left;} </style> </head> <body> <div id="top"> <div id="con" style="margin-left:0;"> <div class="demo" style="width:900px;"><p>testetestststs</p></div> <div class="demo" style="width:900px;"><p>setestsetsetsetest</p></div> <div class="demo" style="width:900px;"><p>testsettsetsetsets</p></div> </div> </div> <script type="text/javascript"> var $=function(ID){return document.getElementById(ID);} var speed=25; function scroll(){ if(Math.abs(parseInt($("con").style.marginLeft))>=parseInt($("con").childNodes[0].style.width)){ $("con").appendChild($("con").childNodes[0]); $("con").style.marginLeft="0px"; clearTimeout(time); setTimeout(function(){time=setTimeout(scroll,speed);},2000); } else { $("con").style.marginLeft=(parseInt($("con").style.marginLeft)-40)+"px"; time=setTimeout(scroll,speed); } } var time=setTimeout(scroll,speed); </script> </body> </html>