DIV+CSS+JS enables seamless scrolling similar to marquee seamless scrolling compatibility Firefox_javascript tips

Source: Internet
Author: User
Tags setinterval
Div+css+javascript to achieve seamless scrolling, marquee seamless scrolling, seamless scrolling, compatible with Firefox

Using marquee to achieve the end-end connected cycle scrolling effect (ie only):
Copy Code code as follows:

<marquee behavior= "Scroll" contenteditable= "true" onstart= "this.firstchild.innerhtml+=" This.firstChild.innerHTML "scrollamount=" 3 "width=" "onmouseover=" This.stop (); "onmouseout=" This.start (); " >
Here is the content to scroll
</marquee>

Using Div+css+javascript to achieve the end to end connected cycle scrolling effect (compatible with Firefox):
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>div+css+javascript to achieve seamless scrolling, marquee seamless scrolling, seamless scrolling, compatible firefox</title>
<style type= "Text/css" >
#scrollobj {
White-space:nowrap;
Overflow:hidden;
width:500px;
}
</style>
<body>
<div id= "Scrollobj" onmouseover= "javascript:_stop ();" onmouseout= "Javascript:_start ();" >
Here is the content to scroll
</div>
<script language= "javascript" type= "Text/javascript" >
<!--
function Scroll (obj) {

* * to Left/*
var tmp = (obj.scrollleft) + +;
When the scroll bar reaches the right top
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 left end
if (obj.scrollleft >= obj.firstChild.offsetWidth) {
Obj.scrollleft = 0;
}

/* go up/*
var tmp = (obj.scrolltop) + +;
if (obj.scrolltop = = tmp) {
obj.innerhtml + = obj.innerhtml;
//}
if (obj.scrolltop >= obj.firstChild.offsetWidth) {
obj.scrolltop = 0;
//}
}
var _timer = setinterval ("Scroll (document.getElementById (' scrollobj ')", 20);
function _stop () {
if (_timer!= null) {
Clearinterval (_timer);
}
}
function _start () {
_timer = SetInterval ("_scroll (document.getElementById (' scrollobj ')"), 20);
}
-->
</script>
</body>
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.