日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

switchable图片切换

發(fā)布時(shí)間:2024/3/24 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 switchable图片切换 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前提: 最近由于項(xiàng)目的需要jquery "switchable圖片切換"效果 所以趁著周末有空時(shí)間研究下 ,以前工作都依賴于kissy框架,所以也沒有綜合的寫過類似的,如下圖所示效果:

?

有左右按鈕 和下面的數(shù)字按鈕 點(diǎn)擊左右按鈕或者數(shù)字按鈕切換到上一屏或者下一屏等。

HTML代碼如下

<div class="wrapper"><div class="focus" id="focus"><ul><li><a href="#"><img src="images/01.jpg"/></a></li><li><a href="#"><img src="images/02.jpg"/></a></li><li><a href="#"><img src="images/03.jpg"/></a></li><li><a href="#"><img src="images/04.jpg"/></a></li></ul></div></div>

css代碼如下:

<style>*{margin:0;padding:0;}body{font-size:12px;color:#222;font-family:Verdana,Arial,Helvetica,sans-serif;background:#f0f0f0;}.clearfix:after{content: ".";display: block;height: 0;clear: both;visibility: hidden;}.clearfix{zoom:1;}ul,li{list-style:none;}img{border:0;}.wrapper{width:800px;margin:0 auto;padding-bottom:50px;}.focus{width:800px;height:280px;overflow:hidden;position:relative;}.focus ul{height:380px;position:absolute;}.focus ul li{float:left;position:relative;width:800px;height:280px;overflow:hidden;}.focus ul li div{position:absolute;overflow:hidden;}.focus .btnBg{position:absolute;width:800px;height:20px;left:0;bottom:0;background:#000;}.focus .btn{position:absolute;width:780px;height:10px;padding:5px 10px;right:0;bottom:0;text-align:right;}.focus .btn span{display:inline-block;_display:inline;_zoom:1;width:25px;height:10px;_font-size:0;margin-left:5px;cursor:pointer;background:#fff;opacity:0.4;filter:alpha(opacity=40);}.focus .btn span.on{background:#fff;opacity:1;filter:alpha(opacity=100);}.focus .preNext{width:45px;height:100px;position:absolute;top:90px;background:url(images/sprite.png) no-repeat 0 0;cursor:pointer;opacity:0.2;filter:alpha(opacity=20);}.focus .current {opacity:0.5;filter:alpha(opacity=50);}.focus .pre{left:0;}.focus .next{right:0;background-position:right top;}</style>

JS代碼如下:

/*** switchable 切換*/$(function(){function SwitchTab() {this.config = {wrapContainer : '#focus', // 焦點(diǎn)圖的外部容器prev : '.prev' , // 上一頁按鈕next : '.next', // 下一頁按鈕autoplay : true, // 是否自動(dòng)播放 默認(rèn)為自動(dòng)time : 3000, // 間隔時(shí)間current : 'current', // 左右按鈕當(dāng)前狀態(tài)on : 'on', // 數(shù)字按鈕當(dāng)前狀態(tài)isNum : true // 是否動(dòng)態(tài)生成數(shù)字按鈕1,2,3,4 默認(rèn)為true };this.cache = {index : 0, //當(dāng)前的索引picTimer : undefined // 保存定時(shí)器的時(shí)間 };}SwitchTab.prototype = {init: function(customConfig){this.config = $.extend(this.config, customConfig || {});var self = this,_config = self.config,_cache = self.cache;var sWidth = $(_config.wrapContainer).width(), //獲取焦點(diǎn)圖外層容器寬度len = $(_config.wrapContainer + ' ul li').length;/* 下面的代碼初始化 數(shù)字按鈕 按鈕半透明 上一頁和下一頁按鈕*/var btn = "<div class='btnBg'></div><div class='btn'>";if(_config.isNum) {for(var i = 0; i < len; i+=1) {btn+= "<span></span>";}}btn += "</div><div class='preNext prev'></div><div class='preNext next'></div>";$(_config.wrapContainer).append(btn);//為小按鈕添加鼠標(biāo)滑入事件,以顯示相應(yīng)的內(nèi)容$(_config.wrapContainer + ' .btn span') && $(_config.wrapContainer + ' .btn span').mouseover(function(){_cache.index = $(_config.wrapContainer + ' .btn span').index(this);t && clearTimeout(t);var t = setTimeout(function(){hover();},100);}).eq(0).trigger("mouseover");function hover(){self.showPics(_cache.index,sWidth);}// 上一頁 下一頁按鈕透明處理$(_config.wrapContainer + ' .preNext').hover(function(){$(this).stop(true,false).addClass(_config.current);},function(){$(this).stop(true,false).removeClass(_config.current);});// 上一頁按鈕$(_config.prev).click(function(){_cache.index--;if(_cache.index == -1) {_cache.index = len - 1;}self.showPics(_cache.index,sWidth);});// 下一頁按鈕 $(_config.next).click(function(){_cache.index++;if(_cache.index == len) {_cache.index = 0;}self.showPics(_cache.index,sWidth);});//本例為左右滾動(dòng),即所有l(wèi)i元素都是在同一排向左浮動(dòng),所以這里需要計(jì)算出外圍ul元素的寬度$(_config.wrapContainer + ' ul').css("width",sWidth * len);if(_config.autoplay) {// 鼠標(biāo)滑到焦點(diǎn)圖時(shí)候 停止自動(dòng)播放 滑出時(shí)自動(dòng)播放$(_config.wrapContainer).hover(function(){_cache.picTimer && clearInterval(_cache.picTimer);},function(){_cache.picTimer = setInterval(function(){self.showPics(_cache.index,sWidth);_cache.index++;if(_cache.index == len) {_cache.index = 0;}},_config.time);}).trigger("mouseleave");} },showPics: function(index,sWidth){var self = this,_config = self.config,nowLeft = -index*sWidth;//通過animate()調(diào)整ul元素滾動(dòng)到計(jì)算出的position$(_config.wrapContainer + " ul").stop(true,false).animate({"left":nowLeft},300); $(_config.wrapContainer + ' .btn span') &&$(_config.wrapContainer + ' .btn span').removeClass(_config.on).eq(index).addClass(_config.on); //為當(dāng)前的按鈕切換到選中的效果 }}new SwitchTab().init({});});

上面都有注釋 就不用解釋了哦!

轉(zhuǎn)載于:https://www.cnblogs.com/tugenhua0707/p/3366395.html

總結(jié)

以上是生活随笔為你收集整理的switchable图片切换的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 综合第一页 | 麻豆changesxxx国产 | 色在线免费视频 | 一级淫片免费 | 黑人导航 | 亚洲激情av| 淫久久| 国产视频在线观看一区 | 一个人在线免费观看www | 999国产精品 | 啊v视频在线观看 | 久久久久久九九九九 | 7777精品视频 | 亚洲成人系列 | 午夜影院a | 一区二区视频网站 | 人妻无码中文字幕 | 国产精品日韩专区 | 黄色片网站免费观看 | 网站毛片 | 欧美呦呦| av影片在线观看 | 成人国产精品一区二区 | 国模精品视频一区二区 | 欧美激情第五页 | 日本不卡中文字幕 | 欧美亚洲自拍偷拍 | www,av在线 | 国产黄色精品网站 | 一区二区三区视频免费观看 | 成年网站在线 | 日本三级网站在线观看 | 欧美顶级毛片在线播放 | а√在线中文网新版地址在线 | 欧美成人视屏 | 在线看h网站 | japanese在线观看 | 爱啪啪av | 日韩欧美国产一区二区在线观看 | 人人插人人 | 人人艹人人爱 | 一级精品视频 | 中国肥胖女人真人毛片 | 丰满少妇高潮一区二区 | 2025av在线播放 | 一级片福利| 狠狠操天天射 | www.777色 | 一区二区国产精品 | 亚洲琪琪 | 狠狠干很很操 | 国产av成人一区二区三区高清 | 国产精品sm调教免费专区 | 美女网站在线免费观看 | 欧美婷婷六月丁香综合色 | 一级不卡毛片 | 亚洲一级中文字幕 | 九热视频在线观看 | 少妇爽| 国产农村妇女精品一区 | 中文字幕二区在线观看 | 偷拍亚洲视频 | 日韩最新av | 德国性经典xxxx性hd | 天堂8在线 | www.日日操 | 亚洲自拍av在线 | 亚洲小视频在线观看 | 日韩黄色网址 | 91人妻一区二区三区 | 79日本xxxxxxxxx18| 95在线视频 | 国产激情综合 | 影音先锋中文字幕在线播放 | 福利视频在线看 | 欧美色偷偷 | 中文字幕精品一区二区三区精品 | 成年人看片网站 | 成人在线播放网站 | 亚洲成人精品一区二区三区 | 蜜桃视频日韩 | 热九九精品 | 欧美精品videos另类日本 | 韩国三级hd中文字幕有哪些 | 日b视频在线观看 | 香蕉黄视频 | 日韩精品在线播放 | 欧美日韩电影一区 | 三级影片在线免费观看 | youjizz中国少妇 | 婷婷中文 | 国产精品综合视频 | 精品女同一区二区 | 精品乱码一区二区三四区视频 | 黄色一级二级 | 狠狠干狠狠搞 | 成人午夜在线免费观看 | 人妖av在线| 91国产丝袜在线播放 |