This article mainly introduces the JS picture seamless, smooth scrolling implementation, the need for friends can refer to the following
Very smooth JS picture scrolling effect code, seamless loop, speed can be customized, mouse hover stop. It is characterized by JS and picture address separation, so you will be easy to dynamically from the database to call the address of each picture, convenient control, so it is very applicable. Code as follows: <! 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=gb2312 "/> <title> picture rolling </title> </head> <body> <style Type= "Text/css" > <!-- #demo { background: #FFF; overflow:hidden; border:1px Dashed #CCC; width:500px; } #demo img { border:3px solid #F2F2F2; } #indemo { float: left; width:800%; } #demo1 { float:left; } #demo2 { float:left; } --> </style> <div id= "Demo" > <div id= "Indemo" > <div id= "Demo1" > <a href= "#" ><imgSrc= "/jscss/demoimg/wall_s1.jpg" border= "0"/></a> <a href= "#" ><img src= "/jscss/demoimg/ Wall_s2.jpg "border=" 0 "/></a> <a href=" # "><img src="/jscss/demoimg/wall_s3.jpg "border=" 0 "/ ></a> <a href= "#" ><img src= "/jscss/demoimg/wall_s4.jpg" border= "0"/></a> <a href= "#" ><img src= "/jscss/demoimg/wall_s5.jpg" border= "0"/></a> <a "#" >< IMG src= "/jscss/demoimg/wall_s6.jpg" border= "0"/></a> </div> <div id= "Demo2" ></ div> </div> </div> <script> <!-- var speed=10; var tab= document.getElementById ("demo"); var Tab1=document.getelementbyid ("Demo1"); var tab2= document.getElementById ("Demo2"); 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 ( MyMar)}; tab.onmouseout=function () {mymar=setinterval (marquee,speed)}; --> </script> </body> </html>