jQuery實(shí)現(xiàn)呼吸輪播圖
本文實(shí)例為大家分享了jQuery實(shí)現(xiàn)呼吸輪播圖的具體代碼,供大家參考,具體內(nèi)容如下
HTML
<div class="all" id='box'>
<div class="screen">
<ul>
<li><img src="images/01.jpg" width="500" height="200" /></li>
<li><img src="images/02.jpg" width="500" height="200" /></li>
<li><img src="images/03.jpg" width="500" height="200" /></li>
<li><img src="images/04.jpg" width="500" height="200" /></li>
<li><img src="images/05.jpg" width="500" height="200" /></li>
</ul>
<ol>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ol>
</div>
<div id="arr">
<span id="left"><</span>
<span id="right">></span>
</div>
</div>
CSS
* {
padding: 0;
margin: 0;
list-style: none;
border: 0;
}
.all {
width: 500px;
height: 200px;
padding: 7px;
border: 1px solid #ccc;
margin: 100px auto;
position: relative;
}
.screen {
width: 500px;
height: 200px;
overflow: hidden;
position: relative;
}
.screen li {
width: 500px;
height: 200px;
overflow: hidden;
float: left;
}
.screen ul {
position: absolute;
left: 0;
top: 0px;
width: 2500px;
}
.all ol {
position: absolute;
right: 10px;
bottom: 10px;
line-height: 20px;
text-align: center;
}
.all ol li {
float: left;
width: 20px;
height: 20px;
background: #fff;
border: 1px solid #ccc;
margin-left: 10px;
cursor: pointer;
}
.all ol li.current {
background: yellow;
}
#arr {
display: none;
}
#arr span {
width: 40px;
height: 40px;
position: absolute;
left: 5px;
top: 50%;
margin-top: -20px;
background: #000;
cursor: pointer;
line-height: 40px;
text-align: center;
font-weight: bold;
font-family: '黑體';
font-size: 30px;
color: #fff;
opacity: 0.3;
border: 1px solid #fff;
}
#arr #right {
right: 5px;
left: auto;
}
JS代碼
$(function () {
var index = 0;
//鼠標(biāo)移入
$('#box').mouseenter(function(){
$('#arr').show();
})
//鼠標(biāo)移出
$('#box').mouseleave(function(){
$('#arr').hide();
})
$('#right').click(function(){
if(index == $('.screen>ul>li').length-1){ //最后一張
index = 0;
}else {
index++;
}
$('.screen>ul>li').eq(index).fadeIn(200).siblings('li').fadeOut(200);
//下方頁(yè)碼對(duì)應(yīng)高亮
$('.screen>ol>li').eq(index).addClass('current').siblings('li').removeClass('current')
})
$('#left').click(function(){
if(index == 0){ //第一張
index = $('.screen>ul>li').length-1;
}else {
index--;
}
$('.screen>ul>li').eq(index).fadeIn(200).siblings('li').fadeOut(200);
//下方頁(yè)碼對(duì)應(yīng)高亮
$('.screen>ol>li').eq(index).addClass('current').siblings('li').removeClass('current')
})
//頁(yè)碼點(diǎn)擊輪播圖片
$('.screen>ol>li').click(function(){
index = $(this).index()
$('.screen>ul>li').eq(index).fadeIn(200).siblings('li').fadeOut(200);
$('.screen>ol>li').eq(index).addClass('current').siblings('li').removeClass('current')
})
});
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- jquery實(shí)現(xiàn)無(wú)縫輪播圖
- jQuery呼吸輪播圖制作原理詳解
- jQuery實(shí)現(xiàn)簡(jiǎn)單的輪播圖效果
- 用jquery實(shí)現(xiàn)輪播圖效果
- jquery插件實(shí)現(xiàn)輪播圖效果
- JS+JQuery實(shí)現(xiàn)無(wú)縫連接輪播圖
- Swiper如何實(shí)現(xiàn)兩行四列輪播圖效果實(shí)例
- bootstrap實(shí)現(xiàn)輪播圖效果
- Bootstrap實(shí)現(xiàn)基于carousel.js框架的輪播圖效果
- jQuery實(shí)現(xiàn)的超簡(jiǎn)單輪播圖功能示例【代碼解釋】
相關(guān)文章
jQuery實(shí)現(xiàn)可以計(jì)算進(jìn)制轉(zhuǎn)換的計(jì)算器
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)可以計(jì)算進(jìn)制轉(zhuǎn)換的計(jì)算器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-10-10
jQuery中JSONP的兩種實(shí)現(xiàn)方式詳解
這篇文章主要介紹了jQuery中JSONP的兩種實(shí)現(xiàn)方式詳解的相關(guān)資料,需要的朋友可以參考下2016-09-09
jQuery中借助deferred來(lái)請(qǐng)求及判斷AJAX加載的實(shí)例講解
deferred對(duì)象的延遲功能對(duì)jQuery的ajax操作是一個(gè)很大的幫助,尤其是回調(diào)控制,下面我們就來(lái)看一下對(duì)jQuery中借助deferred來(lái)請(qǐng)求及判斷AJAX加載的實(shí)例講解2016-05-05
各式各樣的導(dǎo)航條效果css3結(jié)合jquery代碼實(shí)現(xiàn)
這篇文章主要為大家分享了css3結(jié)合jquery代碼實(shí)現(xiàn)各式各樣的導(dǎo)航條效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
Jquery change(fontsize,background) 改變顏色與背景的代碼
基于Jquery的改變顏色與背景的代碼,對(duì)于學(xué)習(xí)jquery的朋友可以參考下。2010-05-05

