<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