forked from Crise420WMT/crise420wmt.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_slide163.html
76 lines (73 loc) · 2.37 KB
/
list_slide163.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{margin: 0;padding:0;list-style: none;}
#box{overflow:hidden;width:500px;height: 200px;background: silver;position: relative;margin: 100px auto;}
ul{height: 200px;position: absolute;left: 0;top:0;}
ul li{width: 500px;height: 200px;float: left;color: white;font-family: '微软雅黑';font-size: 30px;text-align: center;line-height: 200px;}
ul li:nth-child(1){background: slateblue;}
ul li:nth-child(2){background: skyblue;}
ul li:nth-child(3){background: seagreen;}
ul li:nth-child(4){background: salmon;}
ul li:nth-child(5){background: saddlebrown;}
ol{height: 10px;position: absolute;left: 20px;bottom: 10px;}
ol li{width: 80px;height: 10px;position:relative;background: springgreen;margin: 5px;float: left}
ol li span{width: 0;height: 10px;position: absolute;left: 0;top:0;background: red;}
</style>
<script src="js/move.js"></script>
<script>
window.onload=function(){
var oUl=document.getElementsByTagName('ul')[0];
var aLi=oUl.children;
var oOl=document.getElementsByTagName('ol')[0];
var aBtn=oOl.children;
var oW=aLi[0].offsetWidth;
oUl.style.width=oW*aLi.length+'px';
for(var i=0;i<aBtn.length;i++){
var oSpan=document.createElement('span');
aLi[i].innerHTML=i+1;
aBtn[i].appendChild(oSpan);
}
var aSpan=document.querySelectorAll('div ol li span');
//alert(aSpan[0].tagName);
var iNow=0;
var timer=null;
function next(){
for(var i=0;i<aSpan.length;i++){
aSpan[i].style.width=0; //放在move()外面和里面也有很大不同
};
move(aSpan[iNow],{width:80},{end:function(){
iNow++;
if(iNow==aSpan.length){
iNow=0;
}
move(oUl,{left:-oW*iNow},{end:next});
//end:next()效果上有很大不同---oUl一往左移动,aSpan[i]的width就变成0;
}})
}
next();
}
</script>
</head>
<body>
<div id="box">
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<ol>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ol>
</div>
</body>
</html>