我是靠谱客的博主 矮小小熊猫,这篇文章主要介绍jquery Banner轮播选项卡,现在分享给大家,希望可以做个参考。

本文实例为大家分享了jquery Banner轮播选项卡的具体代码,供大家参考,具体内容如下

复制代码
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
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> .wraper{ width: 1200px; margin: 0 auto; position: relative; } .banner{ width: 100%; position: relative; height: 460px; } .banner ul{ position:absolute; left:0; top:0; width:10000px; } .ba_slider{ width:1920px; height:460px; position:absolute; overflow: hidden; left: 50%; margin-left: -960px; } .ba_center{ position: absolute; height: 460px; left: 50%; top: 0; margin-left:-600px; } .ba_slider ul{ position:relative; width: 100000px; } .ba_slider ul li{ position: relative; float: left; } .ba_slider img{ width:1920px; height:460px; } .ba_prev,.ba_next{ width:60px; height:100px; background:rgba(0,0,0,0.5); color:#fff; text-decoration:none; font-size:50px; line-height:100px; text-align:center; position:absolute; top:50%; margin-top:-50px; z-index:99; } .ba_prev{ left:0; } .ba_next{ right:0; } .ba_slider ol{ position:absolute; left:50%; bottom:10px; overflow:hidden; margin-left:-220px; } .ba_slider ol li{ width:100px; height:6px; background:rgb(85,85,85); float:left; margin-right:10px; } .ba_slider ol li.on{ background:#fff; } </style> </head> <body> <div class="banner"> <div class="ba_slider"> <div class="wraper ba_center"> <a class="ba_prev" href="javascript:;"><</a> <a class="ba_next" href="javascript:;">></a> </div> <ul> <li> <a href="javascript:;"> <img src="http://scimg.uoften.com/allimg/140708/11-140FQ53531Q9.jpg" alt="" /> </a> </li> <li> <a href="javascript:;"> <img src="http://sc.uoften.com/uploads/allimg/140520/10-140520212515A9.jpg" alt="" /> </a> </li> <li> <a href="javascript:;"> <img src="http://www.uoften.com/uploadfile/2018/0411/20180411024650651.jpg" alt="" /> </a> </li> <li> <a href="javascript:;"> <img src="http://www.uoften.com/uploadfile/2018/0411/20180411024702650.jpg" alt="" /> </a> </li> </ul> <ol> <li class="on"></li> <li></li> <li></li> <li></li> </ol> </div> </div> </body> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script> <script> cBanner(); function cBanner(){ var iNow=0; //初始化自定义值 var w = $('.ba_slider ul img').width(); //获取图片宽度 function bTimer(){ //定时器 clearInterval(b_timer); //先关后开 var b_timer = setInterval(function(){ iNow++; if(iNow == $('.ba_slider ul li').length){ //判断是否最后一张图片 iNow=0; } tab(); //当前分页器高亮 $('.ba_slider ul').eq(0).animate({ //ul运动距离 left:-iNow*w },1000); },2000); //定时器时间 $('.ba_slider').mouseover(function(){ //鼠标移入关闭定时器 clearInterval(b_timer); }); } bTimer(); //定时器函数调用 $('.ba_slider').mouseout(function(){ //鼠标移出调用定时器 bTimer(); }); $('.ba_next').click(function (){ //点击切换下一个图片 iNow++; if(iNow==$('.ba_slider ul li').length){ //判断iNow是否为最后一张图片 iNow=0; } $('.ba_slider ul').eq(0).animate({ //运动距离 left:-iNow*w },1000); tab(); //当前分页器高亮 }); $('.ba_prev').click(function (){ //点击切换上一个 iNow--; if(iNow==-1){ //判断是否是第一张图片 iNow = $('.ba_slider ul li').length-1 ; } $('.ba_slider ul').eq(0).animate({ //运动距离 left:-iNow*w },1000); tab(); //当前分页器高亮 }); $('ol li').click(function (){ //点击分页器选择图片 iNow=$(this).index(); //iNow赋值为当前分页器索引值 $('.ba_slider ul').eq(0).animate({ left:-iNow*w },1000); tab(); }); function tab(){ //分页器高亮效果 $('ol li').removeClass('on'); $('ol li').eq(iNow).addClass('on'); } }; </script> </html>

github地址:https://github.com/seven-it/jqBanner

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

最后

以上就是矮小小熊猫最近收集整理的关于jquery Banner轮播选项卡的全部内容,更多相关jquery内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(131)

评论列表共有 0 条评论

立即
投稿
返回
顶部