-
Notifications
You must be signed in to change notification settings - Fork 0
/
20161112轮播图无缝连接2.html
121 lines (117 loc) · 2.92 KB
/
20161112轮播图无缝连接2.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
*{
padding: 0;
margin: 0;
}
ul,ol{
list-style: none;
}
#container{
width: 500px;
height: 400px;
position: relative;
top: 120px;
left: 200px;
}
#content{
height: 400px;
position: absolute;
left: 0;
}
#content div{
height: 400px;
width: 500px;
float: left;
/*position: absolute;*/
/*left: 0;*/
/*top: 0;*/
}
#tab{
position: absolute;
right: 20px;
bottom: 20px;
z-index: 999999;
}
#tab li{
height: 20px;
width: 20px;
line-height: 20px;
text-align: center;
background-color: black;
color: #ffffff;
float: left;
margin-right: 5px;
cursor: pointer;
}
#tab .selected{
background-color:orange ;
}
#arrow{
position: absolute;
left: 20px;
bottom: 20px;
z-index: 999999;
}
#arrow span{
height: 20px;
width: 20px;
background-color: black;
color: #ffffff;
line-height: 20px;
text-align: center;
float: left;
margin-right: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<div id="container">
<div id="content">
<div style="background-color: cornflowerblue"></div>
<div style="background-color: #999999"></div>
<div style="background-color: #CCCCCC"></div>
<div style="background-color: cadetblue"></div>
</div>
<div id="tab">
<ul>
<li class="selected">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
<div id="arrow">
<span id="prev"><</span>
<span id="next">></span>
</div>
</div>
<script src="jslib.js"></script>
<script>
var oContent = document.getElementById('content');
var aDiv = oContent.getElementsByTagName('div');
var oTab = document.getElementById('tab');
var aLi = oTab.getElementsByTagName('li');
var newDiv = aDiv[0].cloneNode();
oContent.appendChild(newDiv);
oContent.style.width = aDiv.length * aDiv[0].offsetWidth +'px';
for(var i=0;i<aLi.length;i++){
aLi[i].index=i;
aLi[i].onclick = function(){
}
}
function change(index){
for(var i = 0 ;i<aLi.length;i++){
aLi[i].className = '';
}
aLi[index==aDiv.length-1 ? 0:index].className='selected';
animate(oContent,{left:-aDiv[O].offsetWidth*index});
}
</script>
</body>
</html>