本文实例为大家分享了jQuery实现轮播图效果的具体代码,供大家参考,具体内容如下
效果展示:

编程思路:
1. 首先是基础的布局,使用”子绝父相”等页面布局方法,将图片、左右按钮以及每张图片下方对应的标识小按钮安排的明明白白。
2. JS中在通过点击左右按钮来切换图片时,使用三个变量分别来表示当前显示的图片序号、点击上一张按钮时候显示的图片序号、点击下一张按钮时候显示的图片序号。
3. 在自动轮播的时候,通过使用定时器来改变当前显示的图片序号来控制轮播
具体代码:
HTML代码:
<div id="slideShow">
<a href="#" class="slide_pic"><img src="../img/phone_photo/p1.jpg" alt="0"></a>
<a href="#" class="slide_pic"><img src="../img/phone_photo/p2.jpg" alt="1"></a>
<a href="#" class="slide_pic"><img src="../img/phone_photo/p3.jpg" alt="2"></a>
<a href="#" class="slide_pic"><img src="../img/phone_photo/p4.jpg" alt="3"></a>
<a href="#" class="slide_pic"><img src="../img/phone_photo/p5.jpg" alt="4"></a>
<a href="#" class="slide_pic"><img src="../img/phone_photo/p6.jpg" alft="5"></a> <button class="prev_one"> < </button>
<button class="next_one"> > </button>
<ul id="mark_box">
<li class="mark">1</li>
<li class="mark">2</li>
<li class="mark">3</li>
<li class="mark">4</li>
<li class="mark">5</li>
<li class="mark">6</li>
</ul>
</div>
CSS代码:
#slideShow{
width: 330px;
height: 245px;
background-color: #999999;
text-align: center;
left: 50%;
margin-left: -165px;
position: relative;
}
#slideShow .slide_pic{
position: absolute;
left: 0;
top: 0;
}
#slideShow .prev_one{
position: absolute;
left: 0;
top: 45%;
}
#slideShow .next_one{
position: absolute;
right: 0;
top: 45%;
}
#slideShow #mark_box{
position: absolute;
bottom: 0;
}#mark_box .mark{
width: 20px;
height: 20px;
border-radius: 20px;
padding: 2px;
text-align: center;
line-height: 20px;
background-color: red;
float: left;
list-style: none;
margin: 10px 10px;
cursor: pointer;
}
#mark_box .active_img{
background-color: green;
}
Javascript代码:










