jquery左右滾動(dòng)焦點(diǎn)圖banner圖片鼠標(biāo)經(jīng)過顯示上下頁按鈕
更新時(shí)間:2013年10月11日 15:18:50 作者:
jquery左右滾動(dòng)焦點(diǎn)圖banner圖片,鼠標(biāo)經(jīng)過顯示上下頁,適合寬和高都比較大的頁面使用附演示,感興趣的朋友可以參考下
jquery左右滾動(dòng)焦點(diǎn)圖banner圖片,鼠標(biāo)經(jīng)過顯示上下頁
適合寬和高都比較大的頁面使用
演示
<div class="bannerbox">
<div id="focus">
<ul>
<li><a target="_blank">
<img src="../dandong.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../mohe.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../changbaishan.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../erlianhaote.png" alt="" /></a></li>
</ul>
</div>
</div>
@charset "utf-8";
img { border: 0px; }
.bannerbox { width: 320px; height: 150px; overflow: hidden; margin: 0px auto; }
#focus { width: 320px; height: 150px; clear: both; overflow: hidden; position: relative; float: left; }
#focus ul { width: 320px; height: 150px; float: left; position: absolute; clear: both; padding: 0px; margin: 0px; }
#focus ul li { float: left; width: 320px; height: 150px; overflow: hidden; position: relative; padding: 0px; margin: 0px; }
#focus .preNext { width: 250px; height: 150px; position: absolute; top: 0px; cursor: pointer; }
#focus .pre { left: 0; background: url(../images/sprite.png) no-repeat left center; }
#focus .next { rightright: 0; background: url(../images/sprite1.png) no-repeat rightright center; }
js文件
$(function () {
var sWidth = $("#focus").width();
var len = $("#focus ul li").length;
var index = 0;
var picTimer;
var btn = "<div class='btnBg'></div><div class='btn'>";
for (var i = 0; i < len; i++) {
btn += "<span></span>";
}
btn += "</div><div class='preNext pre'></div><div class='preNext next'></div>";
$("#focus").append(btn);
$("#focus .btnBg").css("opacity", 0);
$("#focus .btn span").css("opacity", 0.4).mouseenter(function () {
index = $("#focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
$("#focus .preNext").css("opacity", 0.0).hover(function () {
$(this).stop(true, false).animate({ "opacity": "0.5" }, 300);
}, function () {
$(this).stop(true, false).animate({ "opacity": "0" }, 300);
});
$("#focus .pre").click(function () {
index -= 1;
if (index == -1) { index = len - 1; }
showPics(index);
});
$("#focus .next").click(function () {
index += 1;
if (index == len) { index = 0; }
showPics(index);
});
$("#focus ul").css("width", sWidth * (len));
$("#focus").hover(function () {
clearInterval(picTimer);
}, function () {
picTimer = setInterval(function () {
showPics(index);
index++;
if (index == len) { index = 0; }
}, 2800);
}).trigger("mouseleave");
function showPics(index) {
var nowLeft = -index * sWidth;
$("#focus ul").stop(true, false).animate({ "left": nowLeft }, 300);
$("#focus .btn span").stop(true, false).animate({ "opacity": "0.4" }, 300).eq(index).stop(true, false).animate({ "opacity": "1" }, 300);
}
});
適合寬和高都比較大的頁面使用

演示
復(fù)制代碼 代碼如下:
<div class="bannerbox">
<div id="focus">
<ul>
<li><a target="_blank">
<img src="../dandong.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../mohe.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../changbaishan.png" alt="" /></a></li>
<li><a target="_blank">
<img src="../erlianhaote.png" alt="" /></a></li>
</ul>
</div>
</div>
復(fù)制代碼 代碼如下:
@charset "utf-8";
img { border: 0px; }
.bannerbox { width: 320px; height: 150px; overflow: hidden; margin: 0px auto; }
#focus { width: 320px; height: 150px; clear: both; overflow: hidden; position: relative; float: left; }
#focus ul { width: 320px; height: 150px; float: left; position: absolute; clear: both; padding: 0px; margin: 0px; }
#focus ul li { float: left; width: 320px; height: 150px; overflow: hidden; position: relative; padding: 0px; margin: 0px; }
#focus .preNext { width: 250px; height: 150px; position: absolute; top: 0px; cursor: pointer; }
#focus .pre { left: 0; background: url(../images/sprite.png) no-repeat left center; }
#focus .next { rightright: 0; background: url(../images/sprite1.png) no-repeat rightright center; }
js文件
復(fù)制代碼 代碼如下:
$(function () {
var sWidth = $("#focus").width();
var len = $("#focus ul li").length;
var index = 0;
var picTimer;
var btn = "<div class='btnBg'></div><div class='btn'>";
for (var i = 0; i < len; i++) {
btn += "<span></span>";
}
btn += "</div><div class='preNext pre'></div><div class='preNext next'></div>";
$("#focus").append(btn);
$("#focus .btnBg").css("opacity", 0);
$("#focus .btn span").css("opacity", 0.4).mouseenter(function () {
index = $("#focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
$("#focus .preNext").css("opacity", 0.0).hover(function () {
$(this).stop(true, false).animate({ "opacity": "0.5" }, 300);
}, function () {
$(this).stop(true, false).animate({ "opacity": "0" }, 300);
});
$("#focus .pre").click(function () {
index -= 1;
if (index == -1) { index = len - 1; }
showPics(index);
});
$("#focus .next").click(function () {
index += 1;
if (index == len) { index = 0; }
showPics(index);
});
$("#focus ul").css("width", sWidth * (len));
$("#focus").hover(function () {
clearInterval(picTimer);
}, function () {
picTimer = setInterval(function () {
showPics(index);
index++;
if (index == len) { index = 0; }
}, 2800);
}).trigger("mouseleave");
function showPics(index) {
var nowLeft = -index * sWidth;
$("#focus ul").stop(true, false).animate({ "left": nowLeft }, 300);
$("#focus .btn span").stop(true, false).animate({ "opacity": "0.4" }, 300).eq(index).stop(true, false).animate({ "opacity": "1" }, 300);
}
});
您可能感興趣的文章:
- 基于JQuery的實(shí)現(xiàn)圖片輪播效果(焦點(diǎn)圖)
- jquery仿QQ商城帶左右按鈕控制焦點(diǎn)圖片切換滾動(dòng)效果
- jquery焦點(diǎn)圖片切換(數(shù)字標(biāo)注/手動(dòng)/自動(dòng)播放/橫向滾動(dòng))
- jQuery焦點(diǎn)圖切換特效插件封裝實(shí)例
- jQuery焦點(diǎn)圖切換簡易插件制作過程全紀(jì)錄
- Jquery焦點(diǎn)圖實(shí)例代碼
- Jquery 焦點(diǎn)圖 用于圖片展示效果代碼
- jQuery插件實(shí)現(xiàn)帶圓點(diǎn)的焦點(diǎn)圖片輪播切換
- jQuery插件Elastislide實(shí)現(xiàn)響應(yīng)式的焦點(diǎn)圖無縫滾動(dòng)切換特效
- jquery picswitch圖片焦點(diǎn)圖展示效果
- jQuery插件bxSlider實(shí)現(xiàn)響應(yīng)式焦點(diǎn)圖
- jQuery實(shí)現(xiàn)的自適應(yīng)焦點(diǎn)圖效果完整實(shí)例
相關(guān)文章
使用jQuery監(jiān)聽掃碼槍輸入并禁止手動(dòng)輸入的實(shí)現(xiàn)方法(推薦)
基于jQuery的掃碼槍監(jiān)聽。如果只是想實(shí)現(xiàn)監(jiān)聽獲取條碼掃碼信息,可以直接拿來使用,如果有更多的條碼判斷處理邏輯需要自己擴(kuò)展哦2017-03-03jQuery常用知識(shí)點(diǎn)總結(jié)以及平時(shí)封裝常用函數(shù)
這篇文章主要介紹了jQuery常用知識(shí)點(diǎn)總結(jié)以及平時(shí)封裝常用函數(shù) 的相關(guān)資料,需要的朋友可以參考下2016-02-02jQuery實(shí)現(xiàn)無限往下滾動(dòng)效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)無限往下滾動(dòng)效果代碼,涉及jQuery基于ajax交互操作數(shù)據(jù)庫數(shù)據(jù)及頁面元素動(dòng)態(tài)變換的相關(guān)技巧,需要的朋友可以參考下2016-04-04jquery實(shí)現(xiàn)漂浮在網(wǎng)頁右側(cè)的qq在線客服插件示例
很實(shí)用的一款QQ在線客服代碼,點(diǎn)擊QQ圖標(biāo),可直接與客服對(duì)話,詳細(xì)如下,感興趣的朋友可以參考下哈,希望對(duì)你有所幫助2013-05-05jQuery實(shí)現(xiàn)鼠標(biāo)可拖動(dòng)調(diào)整表格列寬度
這篇文章主要介紹了通過jQuery實(shí)現(xiàn)鼠標(biāo)可拖動(dòng)調(diào)整表格列寬度,需要的朋友可以參考下2014-05-05jQuery實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖代碼分享
這篇文章主要介紹了jQuery實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖效果,功能實(shí)現(xiàn)非常簡單,推薦給大家,有需要的小伙伴可以參考下。2015-08-08終于實(shí)現(xiàn)了!精彩的jquery彈幕效果
終于實(shí)現(xiàn)精彩的jquery彈幕效果了,這篇文章就為大家詳細(xì)介紹了jquery彈幕效果的實(shí)現(xiàn)代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07