Javascript实现图片无缝滚动
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>向左无缝滚动</title> <style type="text/css"> body,html,div,a{ margin:0 auto; padding:0} #scroll_top { background: #FFF; overflow:hidden; border: 1px dashed #CCC; width: 98%; } #scroll_top img { border: 3px solid #F2F2F2; } #scroll_main { float: left; width: 800%; } #scroll1 { float: left; } #scrol2 { float: left; margin-left:7px; } </style> <script type="text/javascript"> window.onload = function(){ var speed=50;var tab=document.getElementById("scroll_top"); var tab1=document.getElementById("scroll1"); var tab2=document.getElementById("scrol2"); tab2.innerHTML=tab1.innerHTML; function Marquee(){ if(tab2.offsetWidth-tab.scrollLeft<=0) tab.scrollLeft-=tab1.offsetWidth else{ tab.scrollLeft++; } } var MyMar=setInterval(Marquee,speed); tab.onmouseover=function() {clearInterval(MyMar)}; tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; } </script> </head> <body> <div id="scroll_top"> <div id="scroll_main"> <div id="scroll1"> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> <img src="http://www.google.com/images/errors/robot.png" alt="404" /> </div> <div id="scrol2" ></div> </div> </div> </body> </html>
上面還有一篇是用jquery做的圖片無縫滾動。http://www.cnblogs.com/dying/p/3394529.html
Live Like You're Dying And Never Stop Tying