This article is an example of JS simple to achieve seamless scrolling effect. Share to everyone for your reference, specific as follows:
<!doctype html> <title>javascript Seamless scrolling </title> <meta charset= "Utf-8"/> <meta name= " Keywords "content=" javascript seamless scrolling "/> <meta name=" description "content=" JavaScript seamless scrolling "/> <style type="
Text/css "> H1 {font:400 16px/1" Microsoft Yahei, kaiti_gb2312, SimSun} #marquee {position:relative;
width:400px;
Overflow:hidden;
border:10px solid #8080C0;
#marquee img {border:0px;
#marquee DL, #marquee DT, #marquee DD, #marquee a {float:left;
margin:0;
padding:0;
} #marquee dl {width:1000%;
height:150px; } </style> <script type= "Text/javascript" > var Marquee = function (id) {try {Document.execcommand ("back
Groundimagecache ", false, true);
catch (e) {}; var container = document.getElementById (id), original = Container.getelementsbytagname ("DT") [0], clone = Container . getElementsByTagName ("dd") [0], speed = Arguments[1] | |
10; Clone.innerhtml = original.innerhtml; Container.scrollleft = clone.offsetleft var rolling = function () {if (Container.scrollleft = = 0) {CONTAINER.S
Crollleft = Clone.offsetleft;
else {container.scrollleft--;
} var timer = SetInterval (rolling, speed)//Set Timer Container.onmouseover = function () {clearinterval (timer) ////mouse over Marquee, clear timer, stop scrolling container.onmouseout = function () {timer = SetInterval (rolling, speed)}/////mouse move away Reset Timer} window.onload = function () {Marquee ("Marquee");} </script>
The effect chart is as follows:
More readers interested in JavaScript-related content can view the site topics: "JavaScript switching effects and tips summary", "JavaScript Search Algorithm Skills Summary", "JavaScript animation effects and tips summary", " JavaScript error and debugging skills Summary, JavaScript data structure and algorithm skills summary, JavaScript traversal algorithm and skills summary and JavaScript mathematical calculation usage Summary
I hope this article will help you with JavaScript programming.