-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.html
352 lines (315 loc) · 9.61 KB
/
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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body, html {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
overflow-x: hidden;
}
/*.w1104{*/
/*width: 1104px;*/
/*margin: auto;*/
/*border: 2px solid darkgrey;*/
/*}*/
* {
padding: 0;
margin: 0;
}
.container {
max-width: 800px;
margin: 0 auto;
}
.slide {
width: 100%;
min-height: 180px;
position: relative;
}
.slide .img {
overflow: hidden;
position: absolute;
transition: width 0.4s, height 0.4s, top 0.4s, left 0.4s, z-index 0.4s;
-moz-transition: width 0.4s, height 0.4s, top 0.4s, left 0.4s, z-index 0.4s;
-webkit-transition: width 0.4s, height 0.4s, top 0.4s, left 0.4s, z-index 0.4s;
-o-transition: width 0.4s, height 0.4s, top 0.4s, left 0.4s, z-index 0.4s;
}
.slide .img img {
width: 100%;
height: 100%;
/*width: calc(100% - 14px);*/
/*height: calc(100% - 14px);*/
margin: 7px;
}
.slide .img1 {
width: 40%;
height: 40%;
top: 25%;
left: -34%;
z-index: 10;
}
.slide .img2 {
width: 50%;
height: 50%;
top: 20%;
left: -16%;
z-index: 50;
}
.slide .img3 {
width: 65%;
height: 70%;
top: 10%;
left: 14%;
z-index: 100;
}
.slide .img4 {
width: 50%;
height: 50%;
top: 20%;
left: 60%;
z-index: 50;
}
.slide .img5 {
width: 40%;
height: 40%;
top: 25%;
left: 94%;
z-index: 20;
}
.slide .img6,.slide .img7,.slide .img8,.slide .img9,.slide .img10 {
width: 40%;
height:40%;
top: 25%;
left: 94%;
z-index:1
}
.slide-bt span {
width: 24px;
height: 8px;
background: #c9caca;
float: left;
margin: 5px;
border-radius: 4px;
}
.slide .slide-bt .on {
background: #ffd200;
}
button {
width: 50px;
margin: 20px;
}
</style>
</head>
<div class="w1104">
<div class="container">
<div id="slide" class="slide" alt="star" style="height: 448px;">
<div class="img img1" data-slide-imgid="0"><img src="images/1.png"></div>
<div class="img img2" data-slide-imgid="1" onclick="left()"><img src="images/2.png"></div>
<div class="img img3" data-slide-imgid="2"><img src="images/3.png"></div>
<div class="img img4" data-slide-imgid="3" onclick="right()"><img src="images/4.png"></div>
<div class="img img5" data-slide-imgid="4"><img src="images/5.png"></div>
<div class="img img6" data-slide-imgid="5"><img src="images/0.png"></div>
<div class="img img7" data-slide-imgid="5"><img src="images/6.png"></div>
<div class="img img8" data-slide-imgid="5"><img src="images/7.png"></div>
<div class="img img9" data-slide-imgid="5"><img src="images/10.png"></div>
<div class="img img10" data-slide-imgid="5"><img src="images/9.png"></div>
</div>
<div class="left"></div>
<button class="left" onclick="left()">上一页</button>
<button class="right" onclick="right()">下一页</button>
</div>
</div>
</html>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>
<script>
var data = ''
var autoLb = false; //autoLb=true为开启自动轮播
var autoLbtime = 1; //autoLbtime为轮播间隔时间(单位秒)
var touch = false; //touch=true为开启触摸滑动
var slideBt = true; //slideBt=true为开启滚动按钮
var img1 = {
width: '40%',
height: '40%',
top: '25%',
left: '-50%'
};
var img2 = {
width: '60%',
height: '60%',
top: '20%',
left: '-16%',
zIndex: 50
};
var img3 = {
width: '65%',
height: '70%',
top: '10%',
left: '14%',
zIndex: 100
};
var img4 = {
width: '50%',
height: '50%',
top: '20%',
left: '60%',
zIndex: 50
};
var img5 = {
width: '40%',
height: '40%',
top: '25%',
left: '94%',
zIndex: 20
};
var img6 = {
width: '40%',
height: '40%',
top: '30%',
left: '94%',
zIndex: 17
}
var img7 = {
width: '40%',
height: '40%',
top: '30%',
left: '94%',
zIndex: 15
}
var img8 = {
width: '40%',
height: '40%',
top: '30%',
left: '94%',
zIndex: 10
}
var img9 = {
width: '40%',
height: '40%',
top: '30%',
left: '94%',
zIndex:8
}
var img10 = {
width: '40%',
height: '40%',
top: '30%',
left: '94%',
// display: 'none',
zIndex: 1
}
var slideNub;
var size = (document.body.clientWidth || document.documentElement.clientWidth) / 800
//窗口大小改变时改变轮播图宽高
$(window).resize(function () {
$(".slide").height($(".slide").width() * 0.56);
$('.container').css({
width: (document.body.clientWidth || document.documentElement.clientWidth) / size
})
});
$(function () {
$(".slide").height($(".slide").width() * 0.56);
slideNub = $(".slide .img").size();//获取轮播图片数量
console.log(slideNub)
for (i = 0; i < slideNub; i++) {
$(".slide .img:eq(" + i + ")").attr("data-slide-imgId", i);
}
//根据轮播图片数量设定图片位置对应的class
for (i = 0; i < slideNub; i++) {
$(".slide .img:eq(" + i + ")").addClass("img" + (i + 1));
}
slideLi();
});
//右滑动
var flag = false
if ('addEventListener' in window) {
flag = true
}
var transitionAry = [img1, img2, img3, img4, img5];
function right() {
if (flag) {
var fy = new Array();
for (i = 0; i < slideNub; i++) {
fy[i] = $(".slide .img[data-slide-imgId=" + i + "]").attr("class");
}
for (i = 0; i < slideNub; i++) {
if (i == 0) {
$(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[slideNub - 1]);
} else {
$(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[i - 1]);
}
}
} else {
for (i = 0; i < slideNub; i++) {
if (i == 0) {
$(".slide .img[data-slide-imgId=" + i + "]").animate(transitionAry[slideNub - 1])
} else {
$(".slide .img[data-slide-imgId=" + i + "]").animate(transitionAry[i - 1])
}
}
var res = transitionAry.pop();
transitionAry.unshift(res);
}
}
//左滑动
function left() {
if (flag) {
var fy = new Array();
for (i = 0; i < slideNub; i++) {
fy[i] = $(".slide .img[data-slide-imgId=" + i + "]").attr("class");
}
for (i = 0; i < slideNub; i++) {
if (i == (slideNub - 1)) {
$(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[0]);
} else {
$(".slide .img[data-slide-imgId=" + i + "]").attr("class", fy[i + 1]);
}
}
} else {
for (i = 0; i < slideNub; i++) {
if (i == (slideNub - 1)) {
$(".slide .img[data-slide-imgId=" + i + "]").animate(transitionAry[0])
} else {
// console.log(transitionAry[i + 1])
$(".slide .img[data-slide-imgId=" + i + "]").animate(transitionAry[i + 1])
}
}
var res = transitionAry.shift();
transitionAry.push(res);
}
}
//轮播图片左右图片点击翻页
// function imgClickFy(){
// $(".slide .img").removeAttr("onclick");
// $(".slide .img2").attr("onclick","left()");
// $(".slide .img4").attr("onclick","right()");
// }
//修改当前最中间图片对应按钮选中状态
function slideLi() {
var slideList = parseInt($(".slide .img3").attr("data-slide-imgId")) + 1;
$(".slide-bt span").removeClass("on");
$(".slide-bt span[data-slide-bt=" + slideList + "]").addClass("on");
}
//轮播按钮点击翻页
function tz(id) {
var tzcs = id - (parseInt($(".slide .img3").attr("data-slide-imgId")) + 1);
if (tzcs > 0) {
for (i = 0; i < tzcs; i++) {
setTimeout(function () {
right();
}, 1);
}
}
if (tzcs < 0) {
tzcs = (-tzcs);
for (i = 0; i < tzcs; i++) {
setTimeout(function () {
left();
}, 1);
}
}
slideLi();
}
</script>