jQuery實現(xiàn)圖片與文字描述左右滑動自動切換的方法
更新時間:2015年07月27日 13:12:27 作者:西西愛OS
這篇文章主要介紹了jQuery實現(xiàn)圖片與文字描述左右滑動自動切換的方法,涉及jquery實現(xiàn)圖文滑動切換效果的方法,涉及jquery針對頁面元素與樣式的相關(guān)操作技巧,需要的朋友可以參考下
本文實例講述了jQuery實現(xiàn)圖片與文字描述左右滑動自動切換的方法。分享給大家供大家參考。具體如下:
這里使用jQuery制作CSS左右圖片無縫滾動自動切換的焦點圖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ù)此計算偏移量 var indent = 50; //標(biāo)題隱藏時往回走的一小段長度 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>今天在瀏覽一個國外網(wǎng)站時候發(fā)現(xiàn)他的網(wǎng)站菜單很美啊 讓我情不自禁地想去偷她!漸漸地我就神志不清拿出firebug開始和她交流拉!等我偷玩后我已經(jīng)愛上這款很漂亮純css打造的菜單導(dǎo)航,愛微網(wǎng)現(xiàn)在無私地分享給大家!只有一個愿望:大家好好珍惜她吧大家好好珍惜她吧大家好好珍惜她吧...<a href="/zhenxmrong/">[查看詳細(xì)]</a></p> </li> <li class="clearfix"> <div class="imgBox"><img src="images/1212/1-12121Q212324Y.jpg" alt="自己做的jQuery展開收起效果" /></div> <h5>自己做的jQuery展開收起效果</h5> <p>今天唯美搭配網(wǎng)剛做的jquery下拉收縮特效,用jquery做的很簡單,適合jquery入門者,主要用到j(luò)query的slideToggle(),這個函數(shù)本身就是下拉收縮的最佳選擇 今天剛做的jquery下拉收縮特效,用jquery做的很簡單,適合jquery入門者,主要用到j(luò)query的slideToggle(),這個函數(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è) 個人商城 淘寶商城 使用 代碼很簡潔 想添加QQ或淘寶在線客服 只要修改HTML標(biāo)簽 TABLE表格 增加和刪除 把里面的參數(shù)改成自己賬號對應(yīng)的參數(shù)就OK拉 這款QQ在線客服 淘寶在線客服特效 大家也許見過!...<a href="/view/442.html">[查看詳細(xì)]</a></p> </li> </ul> </div> </body> </html>
希望本文所述對大家的jquery程序設(shè)計有所幫助。
您可能感興趣的文章:
- 使用jQuery實現(xiàn)鼠標(biāo)點擊左右按鈕滑動切換
- jQuery插件Slider Revolution實現(xiàn)響應(yīng)動畫滑動圖片切換效果
- jQuery實現(xiàn)的Tab滑動選項卡及圖片切換(多種效果)小結(jié)
- jQuery控制元素顯示、隱藏、切換、滑動的方法總結(jié)
- JQuery實現(xiàn)簡單的圖片滑動切換特效
- jQuery實現(xiàn)類似滑動門切換效果的層切換
- multiSteps 基于Jquery的多步驟滑動切換插件
- jQuery實現(xiàn)TAB風(fēng)格的全國省份城市滑動切換效果代碼
- jQuery實現(xiàn)鼠標(biāo)滑動切換圖片
相關(guān)文章
jquery操作select詳解(取值,設(shè)置選中)
本篇文章主要是對jquery操作select(取值,設(shè)置選中)進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-02-02jQuery仿Flash上下翻動的中英文導(dǎo)航菜單實例
這篇文章主要介紹了jQuery仿Flash上下翻動的中英文導(dǎo)航菜單,實例分析了jQuery實現(xiàn)Flash反動特效的技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-03-03jquery 元素控制(追加元素/追加內(nèi)容)介紹及應(yīng)用
一、在元素內(nèi)部/外部追加元素二、在元素的不同位置追加內(nèi)容三、在元素的開始位置追加內(nèi)容四、在不同元素的開始位置追加內(nèi)容等等,感興趣的朋友可以參考下哈2013-04-04easyUI實現(xiàn)類似搜索框關(guān)鍵詞自動提示功能示例代碼
本篇文章主要介紹了easyUI實現(xiàn)類似搜索框關(guān)鍵詞自動提示功能示例代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2016-12-12