| Article Introduction: the picture seamlessly scrolls to the left JavaScript code, this article is an example, the WEBJX netizen may change the picture address to own picture address to browse the test locally. |
The picture seamlessly scrolls to the left JavaScript code, this article is an example, the WEBJX netizen may change the picture address to own picture address to browse the test locally.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> picture seamlessly scroll to the left JavaScript code-web teaching Network webjx.com</title>
<style type= "Text/css" >
. clearfix:after {content: "."; display:block; height:0; visibility:hidden; clear:both;}
. clearfix {*zoom:1}
Body{background:gray;}
#wrap {width:810px; height:160px;
BORDER:1PX solid black;
position:relative;
left:50%;
top:50%;
margin-left:-410px;
margin-top:200px;
Background: #fff;
Overflow:hidden;}
#wrap ul{margin:0px;
padding:0px;
Position:absolute;
top:0px;
left:0px;}
#wrap ul li{List-style:none; float:left;margin:5px 10px;width:265px;}
#wrap ul Li img{border:1px black solid; padding:10px;}
</style>
<script type= "Text/javascript" >
function Slide (obj,direction,speed) {
This.container=document.getelementbyid (obj);
This.content=this.container.getelementsbytagname ("ul") [0];
This.lis=this.content.getelementsbytagname ("Li");
This.imgs=this.content.getelementsbytagname ("img");
this.content.innerhtml+=this.content.innerhtml;
This.content.style.width= (this.lis[0].offsetwidth+20) *this.lis.length+ "px";
var that=this
if (direction== "left") {
This.speed=-speed
}else if (direction== "right") {
This.speed=speed
}
This.time=setinterval (function () {
that.content.style.left=that.content.offsetleft+that.speed+ "px";
if (that.content.offsetLeft <=-that.content.offsetwidth/2) {
That.content.style.left = "0px";
}else if (That.content.offsetLeft >=0) {
That.content.style.left =-that.content.offsetwidth/2 + "px";
}
},30)
for (Var i=0;i<this.imgs.length;i++) {
That.imgs[i].onmouseover = function () {
Clearinterval (That.time)
}
That.imgs[i].onmouseout=function () {
That.time=setinterval (function () {
that.content.style.left=that.content.offsetleft+that.speed+ "px";
if (that.content.offsetLeft <=-that.content.offsetwidth/2) {
That.content.style.left = "0px";
}else if (That.content.offsetLeft >=0) {
That.content.style.left =-that.content.offsetwidth/2 + "px";
}
},30)
}
}
}
</script>
<script type= "Text/javascript" >
Window.onload=function () {New Slide ("Wrap", "left", 5)}
</script>
<body>
<div id= "Wrap" >
<ul class= "Clearfix" >
<li><a href= "#" ></a></li>
<li><a href= "#" ></a></li>
<li><a href= "#" ></a></li>
<li><a href= "#" ></a></li>
<li><a href= "#" ></a></li>
</ul>
</div>
</body>