-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path插件1.html
152 lines (135 loc) · 4.87 KB
/
插件1.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>query焦点轮播图</title>
<style type="text/css">
*{ margin: 0; padding: 0; text-decoration: none;}
body { padding: 20px;}
.imgLun { width: 600px; height: 400px; border: 3px solid #333; overflow: hidden; position: relative;}
.list { width: 4200px; height: 400px; position: absolute; z-index: 1;}
.list img { float: left;}
.buttons { position: absolute; height: 10px; width: 100px; z-index: 2; bottom: 20px; left: 250px;}
.buttons span { cursor: pointer; float: left; border: 1px solid #fff; width: 10px; height: 10px; border-radius: 50%; background: #333; margin-right: 5px;}
.buttons .on { background: orangered;}
.arrow { cursor: pointer; display: none; line-height: 39px; text-align: center; font-size: 36px; font-weight: bold; width: 40px; height: 40px; position: absolute; z-index: 2; top: 180px; background-color: RGBA(0,0,0,.3); color: #fff;}
.arrow:hover { background-color: RGBA(0,0,0,.7);}
.imgLun:hover .arrow { display: block;}
#prev { left: 20px;}
#next { right: 20px;}
</style>
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
function lunbo (speed,option) {
var container = $('.imgLun');
var list = $('.list');
var buttons = $('.buttons span');
var prev = $('#prev');
var next = $('#next');
var index = 1;
var imgList = $('.list img');
var len = $(".list img").length;
var interval = 3000;
var timer;
var buttonsLen = $(".buttons span").length;
var imgWid = parseInt(imgList.eq(0).css("width")) ;
var i = combine();
//console.log(speed);
function combine (){
Lcloned = imgList.eq(len-1).clone();
Fcloned = imgList.eq(0).clone();
//console.log(imgWid);
Lcloned.insertBefore(imgList.eq(0));
Fcloned.insertAfter(imgList.eq(len-1));
}
function animate (offset) {
var left = parseInt(list.css('left')) + offset;
if (offset>0) {
offset = '+=' + offset;
}
else {
offset = '-=' + Math.abs(offset);
}
list.animate({'left': offset}, speed, function () {
if(left > -200){
list.css('left', -imgWid* len);
}
if(left < (-imgWid * len)) {
list.css('left', -imgWid);
}
showButton();
});
//showButton();
}
function showButton() {
buttons.eq(index-1).addClass('on').siblings().removeClass('on');
}
next.click(function () {
if (list.is(':animated')) {
return;
}
if (index == len) {
index = 1;
}
else {
index += 1;
}
animate(-imgWid);
//showButton();
//$.lunbo(10);
});
prev.click( function () {
if (list.is(':animated')) {
return;
}
if (index == 1) {
index = len;
}
else {
index -= 1;
}
animate(imgWid);
//showButton();
});
buttons.each(function () {
$(this).bind('click', function () {
if (list.is(':animated') || $(this).attr('class')=='on') {
return;
}
var myIndex = parseInt((this).index())+1;
var offset = -imgWid * (myIndex - index);
animate(offset);
index = myIndex;
showButton();
})
});
};
$(function () {lunbo (200)});
</script>
</head>
<body>
<div class="imgLun">
<div class="list" style="left: -600px;">
<!-- <img src="img/5.jpg" alt="1"/>-->
<img src="img/1.jpg" alt="1"/>
<img src="img/2.jpg" alt="2"/>
<img src="img/3.jpg" alt="3"/>
<img src="img/4.jpg" alt="4"/>
<img src="img/5.jpg" alt="5"/>
<!-- <img src="img/1.jpg" alt="5"/>-->
</div>
<div class="buttons">
<span class="on"></span>
<span ></span>
<span ></span>
<span ></span>
<span ></span>
</div>
<a href="javascript:;" id="prev" class="arrow"><</a>
<a href="javascript:;" id="next" class="arrow">></a>
</div>
</body>
</html>
</div>
</body>
</html>