日韩性视频-久久久蜜桃-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ò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 狠狠干在线观看 | 91日韩| 欧美xx在线| 僵尸艳谈 | 美女一级视频 | 夏目彩春娇喘呻吟高潮迭起 | 男人靠女人免费视频网站 | 久操伊人网 | 久久久久看片 | 成人一二区 | 欧美呦呦 | 国产亚洲综合精品 | 麻豆乱码国产一区二区三区 | 一本加勒比波多野结衣 | 国产乱码精品一区二区三区亚洲人 | 婷婷五综合 | 五月天综合视频 | 久久夫妻视频 | 极品美女销魂一区二区三区 | 亚洲精品在 | 黄色片久久久久 | 小泽玛利亚一区二区三区 | 国产精品免费一区二区区 | 美女久久视频 | 深夜福利一区 | 亚州av在线播放 | 91精品一区二区三区综合在线爱 | 午夜无遮挡 | 国产精品乱码久久久久 | 日韩精品免费视频 | 国产suv一区二区 | 可以免费在线观看的av | 日本人dh亚洲人ⅹxx | 最新色网址 | www.色呦呦 | 香蕉福利 | 蜜桃精品久久久久久久免费影院 | 日韩女同一区二区三区 | 日韩精品偷拍 | 经典杯子蛋糕日剧在线观看免费 | 男女午夜爽爽 | 亚洲熟妇av乱码在线观看 | 网站国产| 国产精品一区免费观看 | 奇米影视在线视频 | 深田咏美中文字幕 | 亚洲中文字幕97久久精品少妇 | 88国产精品视频一区二区三区 | av在线电影网站 | 黄色小视频在线免费看 | 美丽的小蜜桃2:美丽人生 | 欧美日韩国产一区二区三区在线观看 | 国产精品无码专区av免费播放 | 激情自拍视频 | 激情总合网 | 亚洲成av人片在线观看无码 | 熟女人妻一区二区三区免费看 | 成人免费在线电影 | 人人人草 | 红桃成人网 | 国产农村乱对白刺激视频 | 日韩欧美视频一区二区三区 | 中文字幕一区二区三区人妻在线视频 | 国产一级片麻豆 | 久久精品视频日本 | 天天免费看av | 久久午夜国产精品 | 中字幕一区二区三区乱码 | www.成人在线观看 | 九色porny自拍视频在线播放 | 国产精品第2页 | 黄网免费视频 | 免费的黄色一级片 | 香蕉视频官网在线观看 | 琪琪色网 | 欧美日韩一区二区三区在线 | 欧美精品免费视频 | 懂色av中文一区二区三区天美 | 顶弄h校园1v1| 日韩第二页 | 污片网址| 成人精品一区二区三区电影 | 亚洲干 | 五月深爱 | 天天看毛片 | 色羞羞 | 婷婷激情丁香 | 国产高清自拍视频 | 欧美黄色大片视频 | 亚洲一区二区影院 | 久久久国产一区二区三区 | 亚洲国产精品成人久久蜜臀 | 成人区人妻精品一熟女 | 久久人妖| a级无遮挡超级高清-在线观看 | 亚洲毛片大全 | 亚洲色偷精品一区二区三区 | 男生操女生动漫 | 99久久精品日本一区二区免费 |