凡夫俗子3715261
2016-10-08 11:35
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<style>
*{margin:0; padding:0;}
#div1{width:600px; height:120px; margin:100px auto; position:relative; background:red;}
#div ul{position:absolute; left:0; top:0;}
#div1 ul li{float:left; width:150px;height:120px; list-style:none;}
</style>
<script>
window.onload=function ()
{
var oDiv=document.getElementById("div1");
var oUl=oDiv.getElementsByTagName("ul") [0];
setInterval(function (){
oUl.style.left=oUl.offsetLeft-2+"px";
}, 30);
};
</script>
</head>
<body>
<div id="div1">
<ul>
<li><img src="img3/hot5.jpg"/></li>
<li><img src="img3/hot6.jpg"/></li>
<li><img src="img3/hot7.jpg"/></li>
<li><img src="img3/hot8.jpg"/></li>
</ul>
</div>
</body>
</html>
style里的这句#div ul{position:absolute; left:0; top:0;},id写错了
DOM事件探秘
99544 学习 · 1197 问题
相似问题