JS Seamless Scrolling

Source: Internet
Author: User

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>

<title> Untitled Document </title>

<style type= "Text/css" >

*{MARGIN:0PX;PADDING:0XP;} Default global margin 0, inner margin 0

#div1 {width:800px;height:200px;margin:100px auto;position:relative;background:black;overflow:hidden}// Relative relative positioning, overflow out of bounds hidden

#div1 ul{border:1px Black solid;padding:0px;float:left;width:100%;p osition:absolute;left:0px;top:0px;}

#div1 ul li {width:200px;height:200px;float:left;; List-style:none;position:relative;font-size:36px;color:white;}

</style>

<script type= "Text/javascript" >

Window. ()

{

var Odiv1=document.getelementbyid (' Div1 ');

var oul=odiv1.getelementsbytagname (' ul ') [0];

var ali=oul.getelementsbytagname (' Li ');

Add one of the same styles for scrolling replacement

oul.innerhtml=oul.innerhtml+oul.innerhtml;

oul.style.width=ali[0].offsetwidth*ali.length+ ' px ';

Function Demo ()

{

Scroll bar back to leftmost when scroll bar scrolls the width of initial content

if (OUL.OFFSETLEFT<-OUL.OFFSETWIDTH/2)

{

oul.style.left= ' 0 ';

}

oul.style.left=oul.offsetleft-2+ ' px ';

};

var run=setinterval (demo,30);

Put the mouse on pause to move

ODiv1. ()

{

Clearinterval (run);

};

Mouse left to continue scrolling

ODiv1. ()

{

Run=setinterval (demo,30);

};

};


</script>


<body>

<div id= "Div1" >

<ul>

<li style= "background-color:red" >1</li>

<li style= "Background-color:green" >2</li>

<li style= "Background-color:yellow" >3</li>

<li style= "Background-color:blue" >4</li>

</ul>

</div>

</body>


This article is from the "12380959" blog, please be sure to keep this source http://12390959.blog.51cto.com/12380959/1903911

JS Seamless Scrolling

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.