JS text transverse scrolling special effects _javascript skills

Source: Internet
Author: User
Tags setinterval

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.