亚洲免费在线视频-亚洲啊v-久久免费精品视频-国产精品va-看片地址-成人在线视频网

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

原生js滑動(dòng)輪播封裝

瀏覽:136日期:2024-04-27 14:48:59

本文實(shí)例為大家分享了原生js滑動(dòng)輪播的具體代碼,供大家參考,具體內(nèi)容如下

封裝滑動(dòng)輪播

<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <meta http-equiv='X-UA-Compatible' content='ie=edge'> <title>cmm無(wú)縫輪播</title> <style type='text/css'> *{margin: 0 ;padding : 0} #container{ height: 470px; width: 590px; border: 1px solid red; position: relative; margin: 50px auto; } #box{ position: absolute; list-style: none; } #box li{ float: left; } #pages { width: 100%; height: 30px; background: #ccc; position: absolute; bottom: 0; } #pages i { width: 20px; height: 20px; display: inline-block; border-radius: 10px; background: #fff; margin: 5px; } #pages i.current { background: #f00; } #prev, #next { width: 45px; height: 100px; position: absolute; top: 0; bottom: 0; margin: auto; background: #ccc; line-height: 100px; text-align: center; font-size: 40px; color: #fff; } #next { right: 0; } </style></head><body> <div id='container'> <ul id='box'> <li><img src='http://www.lshqa.cn/bcjs/images/1.jpg'></li> <li><img src='http://www.lshqa.cn/bcjs/images/2.jpg'></li> <li><img src='http://www.lshqa.cn/bcjs/images/3.jpg'></li> <li><img src='http://www.lshqa.cn/bcjs/images/4.jpg'></li> </ul> <div id='pages'></div> <div id='prev'><</div> <div id='next'>></div> </div> <script src='http://www.lshqa.cn/bcjs/js/tools.js'></script> <script> var lis = $('li'), length = lis.length, liWidth = lis[0].clientWidth, currentIndex = 0, nextIndex = 1, timer = null, move = null, circls = null, durations = 2000; // 動(dòng)態(tài)設(shè)置ul寬度 $('#box').style.width = length * liWidth + 'px'; // 動(dòng)態(tài)設(shè)置小圓點(diǎn) var html = ''; for(var i = 0 ;i <length ;i++){ html += '<i></i>' } $('#pages').innerHTML= html; circls = $('i'); circls[0].className = 'current'; // 切換動(dòng)畫 move = function(){ // 設(shè)置box運(yùn)動(dòng)終點(diǎn)值 var _left = -1 * nextIndex * liWidth; // 開始動(dòng)畫 animate($('#box'),{left:_left},200) // 修改小圓點(diǎn)樣式 circls[currentIndex].className = ''; circls[nextIndex].className = 'current'; // 修改索引 currentIndex = nextIndex; nextIndex++; if(nextIndex >= length){ nextIndex = 0; } } // 自動(dòng)動(dòng)畫 timer = setInterval(move, durations) // container中鼠標(biāo)移入,移出事件 on($('#container'),'mouseenter',function(){ clearInterval(timer); }) on($('#container'),'mouseleaver',function(){ timer = setInterval(move, durations); }) // 點(diǎn)擊小圓點(diǎn),切換至對(duì)應(yīng)的圖片 on($('#pages'),'click',function(e){ e = e || event; var src = e.target || src.Element; if(src.nodeName === 'I'){ var _index = Array.from(circls).indexOf(src); if(_index === currentIndex){ return } nextIndex = _index; move(); } }) // 點(diǎn)擊翻頁(yè)進(jìn)行切換 on($('#prev'),'click',function(){ nextIndex = currentIndex - 1; if(nextIndex < 0){ nextIndex = length; } move(); }) on($('#next'),'click',function(){ move(); }) </script></body></html>

更多關(guān)于輪播圖效果的專題,請(qǐng)點(diǎn)擊下方鏈接查看學(xué)習(xí)

javascript圖片輪播效果匯總

jquery圖片輪播效果匯總

Bootstrap輪播特效匯總

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 久久免费视频在线 | 国内久久久久影院精品 | 久久精品国产99国产精品免费看 | 亚洲综合视频在线观看 | 女人张开双腿让男人桶完整 | 欧美成人性生活视频 | 欧美一区二区在线观看免费网站 | 在线观看99 | 免费一级a毛片在线播放 | 久久久久国产一级毛片高清片 | 国产成人经典三级在线观看 | 国产成人资源 | 国产免费一级在线观看 | 久久精品免视看国产明星 | 欧美一级毛片不卡免费观看 | 普通话对白国产情侣自啪 | 欧美日a| 黄色一级毛片免费 | 亚洲女人被黑人猛躁进女人 | 手机看片自拍日韩日韩高清 | 99视频有精品视频免费观看 | 自拍偷自拍亚洲精品10p | 久久精品视频在线 | 欧美亚洲视频在线观看 | 成人三级做爰在线视频 | 精品久久久影院 | 久草福利资源网站免费 | 欧美亚洲国产一区 | 久久er国产精品免费观看1 | 亚洲精品综合一区二区三区在线 | 久久毛片免费 | a黄色毛片| 午夜不卡在线 | 国产精品yjizz视频网一二区 | 亚洲三级视频 | 国产成人毛片毛片久久网 | 亚洲综合亚洲 | 久草首页在线观看 | 亚洲成人黄色网址 | 欧美一级大片免费观看 | 久久综合婷婷香五月 |