Use marquee and div + js respectively to achieve the loop and scroll effect of the first and end links, with only three lines of code

Source: Internet
Author: User

Copy codeThe Code is 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>
<TITLE> Use marquee and div + js respectively to achieve the loop rolling effect of the first and end Links </TITLE>
</HEAD>
<BODY>
Use marquee to achieve loop rolling effect (IE only): <br/>
<MARQUEE behavior = "scroll" contenteditable = "true" onstart = "this. firstChild. innerHTML + = this. firstChild. innerHTML; "scrollamount =" 3 "width =" 100 "> <SPAN unselectable =" on "> here is the content to be rolled </SPAN> </MARQUEE>
<Br/> Use DIV + javascript to implement loop scrolling between the beginning and end connections (compatible with firefox): <br/>
<DIV id = "scrolobj" style = "white-space: nowrap; overflow: hidden; width: 500px; "> <span> here is the content to be rolled </span> </DIV>
<Script language = "javascript" type = "text/javascript">
<! --
Function scroll (obj ){
Var tmp = (obj. scrollLeft) ++;
// When the scroll bar reaches the top right of the page
If (obj. scrollLeft = tmp) obj. innerHTML + = obj. innerHTML;
// When the scroll bar scrolls the width of the initial content, the scroll bar returns to the leftmost end.
If (obj. scrollLeft> = obj. firstChild. offsetWidth) obj. scrollLeft = 0;
}
SetInterval ("scroll (document. getElementById ('scrolobj ')", 20 );
// -->
</Script>
</BODY>
</HTML>

Related Article

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.