jQuery實(shí)現(xiàn)圖片與文字描述左右滑動(dòng)自動(dòng)切換的方法
本文實(shí)例講述了jQuery實(shí)現(xiàn)圖片與文字描述左右滑動(dòng)自動(dòng)切換的方法。分享給大家供大家參考。具體如下:
這里使用jQuery制作CSS左右圖片無(wú)縫滾動(dòng)自動(dòng)切換的焦點(diǎn)圖JS特效。一邊飛出一邊變淡的效果非常漂亮,帶小按鈕。
效果圖如下:

具體代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<title>JQUERY圖片切換特效帶標(biāo)題和描述純JS CSS打造 - </title>
<style type="text/css">
/* YUI reset */
* {margin:0; padding:0;}
/* body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { margin:0;padding:0;} */
table {border-collapse:collapse;border-spacing:0;}
fieldset,img { border:0;}
address,caption,cite,code,dfn,em,strong,th,var {font-style:normal;font-weight:normal;}
ol,ul,li {list-style:none;}
caption,th {text-align:left;}
h1,h2,h3,h4,h5,h6 {font-size:100%;font-weight:normal;}
q:before,q:after {content:'';}
abbr,acronym { border:0;}
/* my */
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix {zoom:1;}
body {color:#333; font-size:12px; font-family:Verdana,Arial,Helvetica,sans-serif;}
a {text-decoration:none; color:#333;}
a:hover {text-decoration:underline;}
.focus {width:600px; height:250px; background:#eee; margin:10px auto; position:relative; overflow:hidden;}
.focus ul {}
.focus li {width:550px; height:200px; padding:25px; position:absolute; left:600px; top:0;}
.focus li h5, .focus li p, .focus li a.button {float:left; position:relative;}
.focus li h5 {width:300px; font-size:22px; font-family:"Microsoft YaHei";}
.focus li p {width:300px; line-height:22px; font-size:14px; margin:1em 0;}
.focus li a.button {width:100px; height:30px; background:#333; cursor:pointer; display:none;}
.focus li a.button:hover {background:#666;}
.focus li div.imgBox {float:right; width:200px; height:200px; position:relative; background:#dddddd;}
.focus li div.imgBox img {width:200px; height:200px;}
.focus .btn {position:absolute; width:600px; height:6px; padding:10px; text-align:center; left:0; bottom:0;}
.focus .btn span {display:inline-block; width:10px; height:6px; background:#999; margin:0 3px;}
.focus .btn span.on {background:#000;}
</style>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var len = $(".focus ul li").length;
var width = 600; //整體寬度,根據(jù)此計(jì)算偏移量
var indent = 50; //標(biāo)題隱藏時(shí)往回走的一小段長(zhǎng)度
var index = 0;
var picTimer;
var btn = "<div class='btn'>";
for(var i = 0; i < len; i++) {
btn += "<span></span>";
}
btn += "</div>";
$(".focus").append(btn);
$(".focus .btn span").mouseenter(function() {
index = $(".focus .btn span").index($(this));
play(index);
}).eq(0).trigger("mouseenter");
$(".focus").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
play(index);
index++;
if(index == len) {index = 0;}
},5000);
}).trigger("mouseleave");
function play(index) {
var $now = $(".focus ul li.on");
if($now.length > 0) {
$now.find("h5").stop(true,true).animate({left:"-" + (width - indent) + "px"},400,function() {
$(this).animate({left:"-"+ (2*width) +"px"},400);
});
$now.find("a.button").stop(true,true).fadeTo(400,0);
var hideDelay = setTimeout(function() {
$now.find("p").stop(true,true).animate({left:"-" + (width - indent) + "px"},400,function() {
$(this).animate({left:"-"+ (2*width) +"px"},400);
$now.find("div.imgBox").stop(true,true).animate({left:"-"+ (2*width) +"px"},400);
});
},200);
var showDelayA = setTimeout(function() {
show(index);
},700);
} else {
show(index);
}
}
function show(index) {
var $next = $(".focus ul li").eq(index);
$next.find("h5").css({left:"0px"});
$next.find("p").css({left:"0px"});
$next.find("a.button").css({left:"0px"});
$next.find("div.imgBox").css({left:"0px"});
$next.find("h5").stop(true,true).animate({left:"-"+ width +"px"},400);
var showDelayB = setTimeout(function() {
$next.find("div.imgBox").stop(true,true).animate({left:"-"+ width +"px"},300);
$next.find("p").stop(true,true).animate({left:"-"+ width +"px"},300,function() {
$next.find("a.button").stop(true,true).animate({left:"-"+ width +"px"},300,function() {$(this).fadeTo(400,1);});
});
},300);
$(".focus .btn span").removeClass("on").eq(index).addClass("on");
$(".focus ul li").removeClass("on").eq(index).addClass("on");
}
});
</script>
</head>
<body>
<div class="focus">
<ul>
<li class="clearfix">
<div class="imgBox"><img src="images/120713/1-120G31F439427.jpg" alt="很漂亮純css打造的菜單導(dǎo)航" /></div>
<h5>很漂亮純css打造的菜單導(dǎo)航</h5>
<p>今天在瀏覽一個(gè)國(guó)外網(wǎng)站時(shí)候發(fā)現(xiàn)他的網(wǎng)站菜單很美啊 讓我情不自禁地想去偷她!漸漸地我就神志不清拿出firebug開(kāi)始和她交流拉!等我偷玩后我已經(jīng)愛(ài)上這款很漂亮純css打造的菜單導(dǎo)航,愛(ài)微網(wǎng)現(xiàn)在無(wú)私地分享給大家!只有一個(gè)愿望:大家好好珍惜她吧大家好好珍惜她吧大家好好珍惜她吧...<a href="/zhenxmrong/">[查看詳細(xì)]</a></p>
</li>
<li class="clearfix">
<div class="imgBox"><img src="images/1212/1-12121Q212324Y.jpg" alt="自己做的jQuery展開(kāi)收起效果" /></div>
<h5>自己做的jQuery展開(kāi)收起效果</h5>
<p>今天唯美搭配網(wǎng)剛做的jquery下拉收縮特效,用jquery做的很簡(jiǎn)單,適合jquery入門(mén)者,主要用到j(luò)query的slideToggle(),這個(gè)函數(shù)本身就是下拉收縮的最佳選擇 今天剛做的jquery下拉收縮特效,用jquery做的很簡(jiǎn)單,適合jquery入門(mén)者,主要用到j(luò)query的slideToggle(),這個(gè)函數(shù)本身就是下拉收縮的... <a href="/js_menu/162.html">[查看詳細(xì)]</a></p>
</li>
<li class="clearfix">
<div class="imgBox"><img src="images/120722/1-120H2102135O8.jpg" alt="QQ和淘寶在線客服JS特效" /></div>
<h5>QQ和淘寶在線客服JS特效</h5>
<p>QQ和淘寶在線客服JS特效左側(cè)懸浮廣告代碼 美觀適合企業(yè) 個(gè)人商城 淘寶商城 使用 代碼很簡(jiǎn)潔 想添加QQ或淘寶在線客服 只要修改HTML標(biāo)簽 TABLE表格 增加和刪除 把里面的參數(shù)改成自己賬號(hào)對(duì)應(yīng)的參數(shù)就OK拉 這款QQ在線客服 淘寶在線客服特效 大家也許見(jiàn)過(guò)!...<a href="/view/442.html">[查看詳細(xì)]</a></p>
</li>
</ul>
</div>
</body>
</html>
希望本文所述對(duì)大家的jquery程序設(shè)計(jì)有所幫助。
- 使用jQuery實(shí)現(xiàn)鼠標(biāo)點(diǎn)擊左右按鈕滑動(dòng)切換
- jQuery插件Slider Revolution實(shí)現(xiàn)響應(yīng)動(dòng)畫(huà)滑動(dòng)圖片切換效果
- jQuery實(shí)現(xiàn)的Tab滑動(dòng)選項(xiàng)卡及圖片切換(多種效果)小結(jié)
- jQuery控制元素顯示、隱藏、切換、滑動(dòng)的方法總結(jié)
- JQuery實(shí)現(xiàn)簡(jiǎn)單的圖片滑動(dòng)切換特效
- jQuery實(shí)現(xiàn)類似滑動(dòng)門(mén)切換效果的層切換
- multiSteps 基于Jquery的多步驟滑動(dòng)切換插件
- jQuery實(shí)現(xiàn)TAB風(fēng)格的全國(guó)省份城市滑動(dòng)切換效果代碼
- jQuery實(shí)現(xiàn)鼠標(biāo)滑動(dòng)切換圖片
相關(guān)文章
jquery操作select詳解(取值,設(shè)置選中)
本篇文章主要是對(duì)jquery操作select(取值,設(shè)置選中)進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02
jQuery仿Flash上下翻動(dòng)的中英文導(dǎo)航菜單實(shí)例
這篇文章主要介紹了jQuery仿Flash上下翻動(dòng)的中英文導(dǎo)航菜單,實(shí)例分析了jQuery實(shí)現(xiàn)Flash反動(dòng)特效的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-03-03
jQuery實(shí)現(xiàn)淡入淡出的模態(tài)框
這篇文章主要為大家詳細(xì)介紹了jQuery實(shí)現(xiàn)淡入淡出的模態(tài)框,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-02-02
jquery 元素控制(追加元素/追加內(nèi)容)介紹及應(yīng)用
一、在元素內(nèi)部/外部追加元素二、在元素的不同位置追加內(nèi)容三、在元素的開(kāi)始位置追加內(nèi)容四、在不同元素的開(kāi)始位置追加內(nèi)容等等,感興趣的朋友可以參考下哈2013-04-04
Jquery樹(shù)插件zTree用法入門(mén)教程
這篇文章主要介紹了Jquery樹(shù)插件zTree用法入門(mén)教程,實(shí)例分析了zTree插件的使用技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-02-02
easyUI實(shí)現(xiàn)類似搜索框關(guān)鍵詞自動(dòng)提示功能示例代碼
本篇文章主要介紹了easyUI實(shí)現(xiàn)類似搜索框關(guān)鍵詞自動(dòng)提示功能示例代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2016-12-12

