商城常用滾動(dòng)的焦點(diǎn)圖效果代碼簡(jiǎn)單實(shí)用
更新時(shí)間:2013年03月28日 14:26:51 作者:
此效果在網(wǎng)上使用的頻率比較多一點(diǎn)但大多是插件,要么JS寫(xiě)的太過(guò)于復(fù)雜童鞋們看起來(lái)有一定的難度,這個(gè)相對(duì)來(lái)說(shuō)比較簡(jiǎn)單一點(diǎn),感興趣的可以參考下哈
這種商城的效果網(wǎng)上很多,但大多是插件,要么JS寫(xiě)的太過(guò)于復(fù)雜,對(duì)于學(xué)習(xí)的童鞋來(lái)說(shuō)看起來(lái)比較費(fèi)勁,這個(gè)看起來(lái)比較簡(jiǎn)單,也比較容易理解,各位童鞋需要的請(qǐng)圍觀,也歡迎各位評(píng)價(jià),貼代碼(為方便使用,代碼復(fù)制即可用,無(wú)需另外添加?xùn)|西):
<!doctype html>
<html lang="en">
<head>
<title>商城常用滾動(dòng)的效果,簡(jiǎn)單實(shí)用</title>
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<script type="text/javascript">
$(function(){
var len = $(".num > li").length;
var index = 0;
var adTimer;
$(".num li").mouseover(function(){
index = $(".num li").index(this);
showImg(index);
}).eq(0).mouseover();
//滑入 停止動(dòng)畫(huà),滑出開(kāi)始動(dòng)畫(huà).
$('.ad').hover(function(){
clearInterval(adTimer);
},function(){
adTimer = setInterval(function(){
showImg(index)
index++;
if(index==len){index=0;}
} , 3000);
}).trigger("mouseleave");
})
// 通過(guò)控制top ,來(lái)顯示不同的幻燈片
function showImg(index){
var adHeight = $(".content .ad").height();
$(".slider").stop(true,false).animate({top : -adHeight*index},1000);
$(".num li").removeClass("on")
.eq(index).addClass("on");
}
</script>
<style type="text/css">
ul,li{ margin:0;padding:0;}
.ad { margin-bottom:10px;width:586px; height:150px; overflow:hidden;position:relative;}
.content .slider,.content .num{position:absolute;}
.content .slider li{list-style:none;display:inline;}
.content .slider img{ width:586px; height:150px;display:block;}
.content .num{ right:5px; bottom:5px;}
.content .num li{float: left;color: #FF7300;text-align: center; line-height: 16px;width: 16px;height: 16px;font-family: Arial; font-size: 12px;cursor: pointer;overflow: hidden;margin: 3px 1px;border: 1px solid #FF7300;background-color: #fff;
}
.content .num li.on{color: #fff;line-height: 21px;width: 21px;height: 21px; font-size: 16px;margin: 0 1px;border: 0;background-color: #FF7300;font-weight: bold;}
</style>
</head>
<body>
<div class="content">
<div class="ad" >
<ul class="slider" >
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-07/1506174974.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
</ul>
<ul class="num" >
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
</body>
</html>
效果圖如下:
復(fù)制代碼 代碼如下:
<!doctype html>
<html lang="en">
<head>
<title>商城常用滾動(dòng)的效果,簡(jiǎn)單實(shí)用</title>
<script type="text/javascript" src="http://jt.875.cn/js/jquery.js"></script>
<script type="text/javascript">
$(function(){
var len = $(".num > li").length;
var index = 0;
var adTimer;
$(".num li").mouseover(function(){
index = $(".num li").index(this);
showImg(index);
}).eq(0).mouseover();
//滑入 停止動(dòng)畫(huà),滑出開(kāi)始動(dòng)畫(huà).
$('.ad').hover(function(){
clearInterval(adTimer);
},function(){
adTimer = setInterval(function(){
showImg(index)
index++;
if(index==len){index=0;}
} , 3000);
}).trigger("mouseleave");
})
// 通過(guò)控制top ,來(lái)顯示不同的幻燈片
function showImg(index){
var adHeight = $(".content .ad").height();
$(".slider").stop(true,false).animate({top : -adHeight*index},1000);
$(".num li").removeClass("on")
.eq(index).addClass("on");
}
</script>
<style type="text/css">
ul,li{ margin:0;padding:0;}
.ad { margin-bottom:10px;width:586px; height:150px; overflow:hidden;position:relative;}
.content .slider,.content .num{position:absolute;}
.content .slider li{list-style:none;display:inline;}
.content .slider img{ width:586px; height:150px;display:block;}
.content .num{ right:5px; bottom:5px;}
.content .num li{float: left;color: #FF7300;text-align: center; line-height: 16px;width: 16px;height: 16px;font-family: Arial; font-size: 12px;cursor: pointer;overflow: hidden;margin: 3px 1px;border: 1px solid #FF7300;background-color: #fff;
}
.content .num li.on{color: #fff;line-height: 21px;width: 21px;height: 21px; font-size: 16px;margin: 0 1px;border: 0;background-color: #FF7300;font-weight: bold;}
</style>
</head>
<body>
<div class="content">
<div class="ad" >
<ul class="slider" >
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-07/1506174974.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-03-26/1504517406.jpg" width="586" height="150"/></li>
<li><img src="http://pic.875.cn/upload/2013-01-24/1634016671.jpg" width="586" height="150"/></li>
</ul>
<ul class="num" >
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
</body>
</html>
效果圖如下:
您可能感興趣的文章:
- jquery 實(shí)現(xiàn)京東商城、凡客商城的圖片放大效果
- 發(fā)一個(gè)php簡(jiǎn)單的偽原創(chuàng)程序,配合商城采集用的
- 萬(wàn)網(wǎng)獨(dú)享主機(jī)Apache為Ecshop商城添加404頁(yè)面的方法詳解
- jQuery實(shí)戰(zhàn)之仿淘寶商城左側(cè)導(dǎo)航效果
- 基于JQuery實(shí)現(xiàn)的類似購(gòu)物商城的購(gòu)物車
- php網(wǎng)上商城購(gòu)物車設(shè)計(jì)代碼分享
- jquery仿京東導(dǎo)航/仿淘寶商城左側(cè)分類導(dǎo)航下拉菜單效果
- jquery仿QQ商城帶左右按鈕控制焦點(diǎn)圖片切換滾動(dòng)效果
- python抓取京東商城手機(jī)列表url實(shí)例代碼
- 使用Nopcommerce為商城添加滿XX減XX優(yōu)惠券功能
相關(guān)文章
jQuery焦點(diǎn)圖切換簡(jiǎn)易插件制作過(guò)程全紀(jì)錄
本文主要講訴了本人制作一個(gè)jquery焦點(diǎn)圖切換的簡(jiǎn)易插件的過(guò)程,十分的詳細(xì),希望對(duì)大家能有所幫助2014-08-08
JQUERY實(shí)現(xiàn)網(wǎng)頁(yè)右下角固定位置展開(kāi)關(guān)閉特效的方法
這篇文章主要介紹了JQUERY實(shí)現(xiàn)網(wǎng)頁(yè)右下角固定位置展開(kāi)關(guān)閉特效的方法,涉及jquery操作頁(yè)面元素的顯示與隱藏等相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07
目前流行的JavaScript庫(kù)的介紹及對(duì)比
為了簡(jiǎn)化JavaScript的開(kāi)發(fā),一些JavaScript程序庫(kù)誕生了,下面是目前集中流行的JavaScript程序庫(kù)的介紹和對(duì)比,感興趣的朋友可以了解下2013-09-09
jQuery列表動(dòng)態(tài)增加和刪除的實(shí)現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于jQuery列表動(dòng)態(tài)增加和刪除的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11
easyui Draggable組件實(shí)現(xiàn)拖動(dòng)效果
Draggable是easyui中用于實(shí)現(xiàn)拖拽功能的一個(gè)插件。利用它,我們可以實(shí)現(xiàn)控件的拖拽效果。Draggble覆蓋默認(rèn)值$.fn.draggable.defaults。2015-08-08

