<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" type="text/css" href="系统CSS初始化.css">
<style>
#l{
width: 220px;
height: 200px;
position: relative;
bottom: 350px;
left: 50px;
}
#r{
width: 220px;
height: 200px;
position: relative;
bottom: 350px;
left: 850px;
}
#div1{
position: relative;
width: 800px;
height: 220px;
margin: 150px auto;
background: red;
overflow: hidden;
}
#div1 ul{
width: 1600px;
height: 220px;
background: rebeccapurple;
position: absolute;
left: 0;
}
#div1 ul img{
width: 200px;
height: 220px;
float: left;
}
</style>
<script>
window.onload=function ()
{
var oDiv1=document.getElementById("div1");
var oUl=document.getElementById("ul1");
var oImg=oDiv1.getElementsByTagName("img");
oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
var oL=document.getElementById("l");
var oR=document.getElementById("r");
var speed=0;
oL.onmousemove=function ( ){
speed=-10;
}
oR.onmousemove=function () {
speed=10;
}
setInterval(function () {
if(oUl.offsetLeft<-800)
{
oUl.style.left=0;
}
if(oUl.offsetLeft>0)
{
oUl.style.left=-800+'px';
}
oUl.style.left=oUl.offsetLeft+speed+'px';
},30)
}
</script>
</head>
<body>
<div id="div1">
<ul id="ul1">
<img src="images/A.jpg">
<img src="images/B.jpg">
<img src="images/C.jpg">
<img src="images/D.jpg">
</ul>
</div>
<img src="images/l.png" id="l">
<img src="images/r.png" id="r">
</body>
</html>