jquery實(shí)現(xiàn)每個(gè)數(shù)字上都帶進(jìn)度條的幻燈片
更新時(shí)間:2013年02月20日 16:35:38 作者:
瀏覽網(wǎng)頁(yè)時(shí)不小心會(huì)碰到這樣的一個(gè)網(wǎng)站有幻燈片而且每個(gè)數(shù)字上面都帶有進(jìn)度條閑的無(wú)聊,自己用jquery實(shí)現(xiàn)了一個(gè),因?yàn)橛幸粋€(gè)進(jìn)度條的播放過(guò)程暫不支持ie6,熱愛(ài)特效的你可不要錯(cuò)過(guò)了哈
記得亞馬遜沒(méi)改版之前,首頁(yè)的幻燈片我很喜歡,每個(gè)數(shù)字上面都帶有進(jìn)度條。
閑的無(wú)聊,自己實(shí)現(xiàn)了一個(gè)。用的jquery。
主要用到animate()方法,
因?yàn)橛幸粋€(gè)進(jìn)度條的播放過(guò)程。
不支持ie6,當(dāng)然,改改還是可以的。
演示
下載
先看下效果圖
看代碼吧:
<!DOCTYPE html>
<html>
<head>
<title>slide play with loadbar--by loethen</title>
<meta charset='utf-8'>
<style>
*{padding: 0;margin:0;}
ul li{list-style: none;}
.slideplay ,.slideshow{
position: relative;
}
.slideshow li{
position: absolute;
left: 0;
top: 0;
display: none;
}
.loadbar{
position: absolute;
bottom: 60px;
left: 250px;
z-index: 9;
}
.loadbar li{
width: 40px;
height: 20px;
float: left;
position: relative;
margin-right: 5px;
border-radius: 2px;
border: 1px solid #e5f9ff;
}
.loadbar span{
position: absolute;
left: 0;
top: 0;
height: 20px;
width: 40px;
text-align: center;
z-index: 12;
cursor: pointer;
color: #fff;
border-radius: 2px;
}
.loadbar em{
position: absolute;
left: 0;
top: 0;
height: 20px;
background: #31d81a;
z-index: 10;
border-radius: 2px;
opacity: 0.7
}
.zindex{
z-index: 1;
}
</style>
<script src='js/jquery.min.js'></script>
</head>
<body>
<div id="slideplay" class='slideplay'>
<ul class='slideshow'>
<li><img src="images/a.jpg" alt=""></li>
<li><img src="images/b.jpg" alt=""></li>
<li><img src="images/c.jpg" alt=""></li>
<li><img src="images/d.jpg" alt=""></li>
<li><img src="images/e.jpg" alt=""></li>
</ul>
<ul class='loadbar clearfix'>
<li>
<span>1</span>
<em></em>
</li>
<li>
<span>2</span>
<em></em>
</li>
<li>
<span>3</span>
<em></em>
</li>
<li>
<span>4</span>
<em></em>
</li>
<li>
<span>5</span>
<em></em>
</li>
</ul>
</div>
<script type='text/javascript'>
$(function(){
var slide = $('.slideplay'),
ulShow = $('.slideshow'),
sLi = ulShow.find('li'),
bLi = $('.loadbar li'),
len = sLi.length;
var option ={
speed:3000,
barWidth:40
},
barSpeed = option.speed-100;
var w = sLi.first().width(),
h = sLi.first().height();
var flag = 0,
timer = null;
ulShow.css({
width:w+'px',
height:h+'px'
});
slide.css({
width:w+'px',
height:h+'px'
});
init();
function init(){
sLi.eq(flag).addClass('zindex').show();
bLi.eq(flag).find('em').animate({width:option.barWidth},barSpeed);
timer = setTimeout(function(){
next();
},option.speed);
ulShow.on('mouseover',doStop);
ulShow.on('mouseleave',doAuto);
bLi.on('mouseover',handPattern);
}
function handPattern(){
doStop();
flag = $(this).index();
imgMove();
bLi.find('em').css('width',0);
bLi.eq(flag).find('em').width(option.barWidth);
}
function doStop(){
timer && clearTimeout(timer);
bLi.eq(flag).find('em').stop();
}
function doAuto(){
var em = bLi.eq(flag).find('em'),
w = em.width(),
leftW = option.barWidth - w ,
sec = (leftW * barSpeed)/option.barWidth;
em.animate({width:option.barWidth},sec,function(){
if(flag==len-1){
em.width(0);
next();
}else{
next();
}
});
}
function next(){
flag++;
flag==len && (flag=0);
doMove();
}
function doMove(){
imgMove();
loadbarMove();
}
function imgMove(){
sLi.eq(flag).addClass('zindex').fadeIn('slow')
.siblings().removeClass('zindex').fadeOut('slow');
}
function loadbarMove(){
bLi.eq(flag).find('em').
animate({width:option.barWidth},barSpeed,function(){
if(flag==len-1){
bLi.find('em').width(0);
next();
}else{
next();
}
});
}
})
</script>
</body>
</html>
閑的無(wú)聊,自己實(shí)現(xiàn)了一個(gè)。用的jquery。
主要用到animate()方法,
因?yàn)橛幸粋€(gè)進(jìn)度條的播放過(guò)程。
不支持ie6,當(dāng)然,改改還是可以的。
演示
下載
先看下效果圖

看代碼吧:
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head>
<title>slide play with loadbar--by loethen</title>
<meta charset='utf-8'>
<style>
*{padding: 0;margin:0;}
ul li{list-style: none;}
.slideplay ,.slideshow{
position: relative;
}
.slideshow li{
position: absolute;
left: 0;
top: 0;
display: none;
}
.loadbar{
position: absolute;
bottom: 60px;
left: 250px;
z-index: 9;
}
.loadbar li{
width: 40px;
height: 20px;
float: left;
position: relative;
margin-right: 5px;
border-radius: 2px;
border: 1px solid #e5f9ff;
}
.loadbar span{
position: absolute;
left: 0;
top: 0;
height: 20px;
width: 40px;
text-align: center;
z-index: 12;
cursor: pointer;
color: #fff;
border-radius: 2px;
}
.loadbar em{
position: absolute;
left: 0;
top: 0;
height: 20px;
background: #31d81a;
z-index: 10;
border-radius: 2px;
opacity: 0.7
}
.zindex{
z-index: 1;
}
</style>
<script src='js/jquery.min.js'></script>
</head>
<body>
<div id="slideplay" class='slideplay'>
<ul class='slideshow'>
<li><img src="images/a.jpg" alt=""></li>
<li><img src="images/b.jpg" alt=""></li>
<li><img src="images/c.jpg" alt=""></li>
<li><img src="images/d.jpg" alt=""></li>
<li><img src="images/e.jpg" alt=""></li>
</ul>
<ul class='loadbar clearfix'>
<li>
<span>1</span>
<em></em>
</li>
<li>
<span>2</span>
<em></em>
</li>
<li>
<span>3</span>
<em></em>
</li>
<li>
<span>4</span>
<em></em>
</li>
<li>
<span>5</span>
<em></em>
</li>
</ul>
</div>
<script type='text/javascript'>
$(function(){
var slide = $('.slideplay'),
ulShow = $('.slideshow'),
sLi = ulShow.find('li'),
bLi = $('.loadbar li'),
len = sLi.length;
var option ={
speed:3000,
barWidth:40
},
barSpeed = option.speed-100;
var w = sLi.first().width(),
h = sLi.first().height();
var flag = 0,
timer = null;
ulShow.css({
width:w+'px',
height:h+'px'
});
slide.css({
width:w+'px',
height:h+'px'
});
init();
function init(){
sLi.eq(flag).addClass('zindex').show();
bLi.eq(flag).find('em').animate({width:option.barWidth},barSpeed);
timer = setTimeout(function(){
next();
},option.speed);
ulShow.on('mouseover',doStop);
ulShow.on('mouseleave',doAuto);
bLi.on('mouseover',handPattern);
}
function handPattern(){
doStop();
flag = $(this).index();
imgMove();
bLi.find('em').css('width',0);
bLi.eq(flag).find('em').width(option.barWidth);
}
function doStop(){
timer && clearTimeout(timer);
bLi.eq(flag).find('em').stop();
}
function doAuto(){
var em = bLi.eq(flag).find('em'),
w = em.width(),
leftW = option.barWidth - w ,
sec = (leftW * barSpeed)/option.barWidth;
em.animate({width:option.barWidth},sec,function(){
if(flag==len-1){
em.width(0);
next();
}else{
next();
}
});
}
function next(){
flag++;
flag==len && (flag=0);
doMove();
}
function doMove(){
imgMove();
loadbarMove();
}
function imgMove(){
sLi.eq(flag).addClass('zindex').fadeIn('slow')
.siblings().removeClass('zindex').fadeOut('slow');
}
function loadbarMove(){
bLi.eq(flag).find('em').
animate({width:option.barWidth},barSpeed,function(){
if(flag==len-1){
bLi.find('em').width(0);
next();
}else{
next();
}
});
}
})
</script>
</body>
</html>
您可能感興趣的文章:
- 基于jquery的多彩百分比 動(dòng)態(tài)進(jìn)度條 投票效果顯示效果實(shí)現(xiàn)代碼
- jQuery EasyUI API 中文文檔 - ProgressBar 進(jìn)度條
- 用jQuery模擬頁(yè)面加載進(jìn)度條的實(shí)現(xiàn)代碼
- 分享8款優(yōu)秀的 jQuery 加載動(dòng)畫和進(jìn)度條插件
- 6款新穎的jQuery和CSS3進(jìn)度條插件推薦
- 基于jQuery實(shí)現(xiàn)模擬頁(yè)面加載進(jìn)度條
- Jquery Uploadify多文件上傳帶進(jìn)度條且傳遞自己的參數(shù)
- Jquery Uploadify上傳帶進(jìn)度條的簡(jiǎn)單實(shí)例
- 一個(gè)簡(jiǎn)單的jquery進(jìn)度條示例
- jquery實(shí)現(xiàn)的一個(gè)簡(jiǎn)單進(jìn)度條效果實(shí)例
- jQuery實(shí)現(xiàn)文件上傳進(jìn)度條特效
- 基于jQuery Bar Indicator 插件實(shí)現(xiàn)進(jìn)度條展示效果
相關(guān)文章
jQuery Mobile框架中的表單組件基礎(chǔ)使用教程
jQuery Mobile框架主要針對(duì)移動(dòng)端的Web UI設(shè)計(jì),其中豐富的表單組件調(diào)用起來(lái)也是相當(dāng)方便,接下來(lái)就為大家整理了一份jQuery Mobile框架中的表單組件基礎(chǔ)使用教程,需要的朋友可以參考下2016-05-05jquery實(shí)現(xiàn)可關(guān)閉的倒計(jì)時(shí)廣告特效代碼
這篇文章主要介紹了jquery實(shí)現(xiàn)可關(guān)閉的倒計(jì)時(shí)廣告特效代碼,涉及jquery計(jì)時(shí)器及鼠標(biāo)事件動(dòng)態(tài)操作頁(yè)面元素樣式的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09jQuery的實(shí)現(xiàn)原理的模擬代碼 -3 事件處理
在 jQuery 中,實(shí)際注冊(cè)的事件處理函數(shù)是一個(gè)匿名的閉包函數(shù),這個(gè)函數(shù)最終都是通過(guò)調(diào)用 jQuery.event.handle 進(jìn)行處理的。2010-08-08鼠標(biāo)懸浮顯示二級(jí)菜單效果的jquery實(shí)現(xiàn)
當(dāng)鼠標(biāo)懸浮時(shí)顯示二級(jí)菜單,這種類似的效果,想必大家在瀏覽網(wǎng)頁(yè)時(shí)經(jīng)常會(huì)遇到吧,下面有個(gè)示例,大家可以看看2014-10-10jQuery的 $.ajax防止重復(fù)提交的兩種方法(推薦)
本文給大家分享兩種jquery 的ajax防止重復(fù)提交的方法,第一種方法對(duì)于onclick事件觸發(fā)的ajax,在beforeSend中使點(diǎn)擊按鈕不可用,ajax結(jié)果返回后置為可用,第二種利用jquery ajaxPrefilter中斷請(qǐng)求,對(duì)于詳情請(qǐng)參考下本文2016-10-10jquery數(shù)組封裝使用方法分享(jquery數(shù)組遍歷)
JQuery對(duì)數(shù)組的處理非常便捷并且功能強(qiáng)大齊全,一步到位的封裝了很多原生js數(shù)組不能企及的功能。下面來(lái)看看JQuery數(shù)組的強(qiáng)大之處在哪。2014-03-03基于jquery的二級(jí)聯(lián)動(dòng)菜單實(shí)現(xiàn)代碼
基于jquery的二級(jí)聯(lián)動(dòng)菜單實(shí)現(xiàn)代碼,腳本之家簡(jiǎn)單整理了幾種。需要的朋友可以參考下,主要是思路2011-04-04