The principle of seamless up/down scrolling in js is as follows: 1. First set the height or width for the container, then overflow: hidden; & amp; nbsp; 2. After the container height is set, if the content is exceeded, it is hidden. 3. Change the scrollTop of the container (scroll up or down)
The principle of seamless up/down scrolling in Javascript is as follows:
1. First set the height or width for the container, and then overflow: hidden;
2. When the container height is set, the content exceeding the limit is hidden.
3. Change the value of the scrollTop attribute of the container to move the content up or down a node (the principle of scrolling );
4. When scrollTop is greater than or equal to the height of the node to be rolled, set scrollTop to 0, move the first node in the subnode tree to the end, and start rolling again, the effect of continuous loop scrolling appears.
The Code is as follows:
Php
Java
Ruby
Python
Www.phpddt.com
Script // speed setting var speed = 1; var colee2 = document. getElementById ("colee2"); var colee1 = document. getElementById ("colee1"); var colee = document. getElementById ("colee"); colee2.innerHTML = response; // clone colee1 to colee2function Marquee1 () {// if (colee2.offsetTop-cole2. scrollTop <= 0) {colee. scrollTop-= colee1.offsetHeight; // colee jump to the top} else {colee. scrollTop ++} var MyMar1 = setInterval (Marquee1, speed) // sets the timer. // when the mouse moves up, the timer is cleared to stop the scroll. onmouseover = function () {clearInterval (MyMar1)} // reset the timer colee when you move the mouse away. onmouseout = function () {MyMar1 = setInterval (Marquee1, speed)} script
As follows: