-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmove-nospace.html
87 lines (65 loc) · 1.7 KB
/
move-nospace.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
*{margin:0px;
padding:0px;}
#div1{width:830px; height:166px; margin:50px auto;
position:relative;
background:white;
overflow:hidden;}
#div1 ul li{float:left; width:174px; height:166px; list-style:none;
}
ul{position:absolute;}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById('div1');
var oUl=oDiv.getElementsByTagName('ul')[0];
var aLi=oUl.getElementsByTagName('li');
var speed=3
oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';
function move (){
if(oUl.offsetLeft<-oUl.offsetWidth/2)
{
oUl.style.left='0';
}
if(oUl.offsetLeft>0)
{
oUl.style.left=-oUl.offsetWidth/2+'px';
}
oUl.style.left=oUl.offsetLeft+speed+'px';
};
var timer=setInterval(move,30);
oDiv.onmouseover=function(){
clearInterval(timer);
};
oDiv.onmouseout=function(){
timer=setInterval(move,30);
}
document.getElementsByTagName('a')[0].onclick=function(){
speed=-3;
};
document.getElementsByTagName('a')[1].onclick=function(){
speed=3;
};
};
</script>
</head>
<body>
<a href="javascipt:;">向左走</a>
<a href="javascipt:;">向右走</a>
<div id="div1">
<ul>
<li><img src="images/b01.jpg" /></li>
<li><img src="images/b02.jpg" /></li>
<li><img src="images/b03.jpg" /></li>
<li><img src="images/b04.jpg" /></li>
<li><img src="images/b05.jpg" /></li>
</ul>
</div>
</body>
</html>