<!DOCTYPE html>
<html>
<head>
<title>refreshAnimation</title>
</head>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById('div1');
var oUl=oDiv.getElementsByTagName('ul')[0];
var aLi=oDiv.getElementsByTagName('li');
oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';
setInterval(function(){
if (oUl.offsetLeft<-oUl.offsetWidth/2)
{
oUl.style.left='0';
}
oUl.style.left=oUl.offsetLeft-3+'px';
},3)
}
</script>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
#div1{
overflow: hidden;
width: 800px;
height: 10px;
background: #eee;
position: relative;
margin: 300px auto;
}
#div1 ul{
position: absolute;
left: 0;
top: 0;
}
#div1 ul li{
width: 200px;
height: 150px;
float: left;
list-style: none;
}
</style>
<body>
<div id="div1">
<ul>
<li><img src="img2/1.png"></li>
<li><img src="img2/2.png"></li>
<li><img src="img2/3.png"></li>
<li><img src="img2/4.png"></li>
</ul>
</div>
</body>
</html>
网友评论