This article for everyone to share the JS text horizontal scrolling effect code, the specific implementation of the following content:
Page Layout
<div id= "Scroll_div" class= "FL" >
<div id= "Scroll_begin" >
congratulations 793765*** get <span class= "Pad_ Right ">50 dollar Giants point card rewards </span>
Congratulations 793765*** get <span class=" Pad_right ">50 yuan Giants dot card rewards </span>
Congratulations 793765*** get <span class= "Pad_right" >50 yuan Giants point Card rewards </span>
Congratulations 793765*** get <span class= "Pad_right" >50 dollar Giants point card rewards </span>
Congratulations 793765*** get <span class= "Pad_right" >50 yuan Giants dot card rewards </span>
Congratulations 793765** * Get <span class= "Pad_right" >50 yuan Giants dot card rewards </span>
Congratulations 793765*** get <span class= "Pad_right" >50 yuan Giants dot card rewards </span>
</div>
<div id= "scroll_end" ></div>
</div>
Style:
. pad_right{Padding-right:2em;}
#scroll_div {height:26px;overflow:hidden;white-space:nowrap;width:535px;margin-left:10px;}
#scroll_begin, #scroll_end {display:inline;}
JS Code:
Text horizontal scrolling
function Scrollimgleft () {
var speed=50;
var MyMar = null;
var scroll_begin = document.getElementById ("Scroll_begin");
var scroll_end = document.getElementById ("Scroll_end");
var scroll_div = document.getElementById ("Scroll_div");
scroll_end.innerhtml=scroll_begin.innerhtml;
function Marquee () {
if (scroll_end.offsetwidth-scroll_div.scrollleft<=0)
scroll_div.scrollleft-= Scroll_begin.offsetwidth;
else
scroll_div.scrollleft++;
}
Mymar=setinterval (marquee,speed);
Scroll_div.onmouseover = function () {
clearinterval (MyMar);
}
scroll_div.onmouseout = function () {
MyMar = setinterval (marquee,speed);
}
}
Scrollimgleft ();
The above is easy to achieve JS text horizontal scrolling effects, you can add in their own Web pages JS text horizontal scrolling effects.