亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

原生js滑動輪播封裝

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

本文實例為大家分享了原生js滑動輪播的具體代碼,供大家參考,具體內容如下

封裝滑動輪播

<!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無縫輪播</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.aoyou183.cn/bcjs/images/1.jpg'></li> <li><img src='http://www.aoyou183.cn/bcjs/images/2.jpg'></li> <li><img src='http://www.aoyou183.cn/bcjs/images/3.jpg'></li> <li><img src='http://www.aoyou183.cn/bcjs/images/4.jpg'></li> </ul> <div id='pages'></div> <div id='prev'><</div> <div id='next'>></div> </div> <script src='http://www.aoyou183.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; // 動態設置ul寬度 $('#box').style.width = length * liWidth + 'px'; // 動態設置小圓點 var html = ''; for(var i = 0 ;i <length ;i++){ html += '<i></i>' } $('#pages').innerHTML= html; circls = $('i'); circls[0].className = 'current'; // 切換動畫 move = function(){ // 設置box運動終點值 var _left = -1 * nextIndex * liWidth; // 開始動畫 animate($('#box'),{left:_left},200) // 修改小圓點樣式 circls[currentIndex].className = ''; circls[nextIndex].className = 'current'; // 修改索引 currentIndex = nextIndex; nextIndex++; if(nextIndex >= length){ nextIndex = 0; } } // 自動動畫 timer = setInterval(move, durations) // container中鼠標移入,移出事件 on($('#container'),'mouseenter',function(){ clearInterval(timer); }) on($('#container'),'mouseleaver',function(){ timer = setInterval(move, durations); }) // 點擊小圓點,切換至對應的圖片 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(); } }) // 點擊翻頁進行切換 on($('#prev'),'click',function(){ nextIndex = currentIndex - 1; if(nextIndex < 0){ nextIndex = length; } move(); }) on($('#next'),'click',function(){ move(); }) </script></body></html>

更多關于輪播圖效果的專題,請點擊下方鏈接查看學習

javascript圖片輪播效果匯總

jquery圖片輪播效果匯總

Bootstrap輪播特效匯總

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 欧美韩日在线 | 免费在线视频一区 | 国产精品欧美一区二区在线看 | 拍拍拍精品视频在线观看 | 视频自拍网 | 女人被免费网站视频在线 | 在线亚洲精品防屏蔽 | 国模福利视频在线播放 | 大片刺激免费播放视频 | 亚洲人在线视频 | 欧美日韩1区 | 嘛豆传媒的短视频动漫 | 免费能直接在线观看黄的视频 | 亚洲 欧美 手机 在线观看 | 久久夜色精品国产尤物 | 乱色视频中文字幕 | 婷婷中文| 在线播放国产真实女同事 | 国产精品分类视频分类一区 | 日韩在线免费视频 | 91夜色视频 | 欧美在线第一二三四区 | 在线国产一区 | 国产精品一区二区三区免费 | 成人污污| 1000部未满岁18在线观看网站 | 久久久一区二区三区 | 妖精视频一区二区三区 | 欧美国产合集在线视频 | 亚洲丶国产丶欧美一区二区三区 | 婷婷精品在线 | 日高千晶在线观看 | 2019理论国产一级中字 | 草草线在成人免费视频 | 国产区网址 | 久久精品视频国产 | 一级片黄色免费 | 久久精品视频99精品视频150 | 精品国产品国语在线不卡丶 | 国产精品亚洲欧美大片在线看 | 泰国一级毛片aaa下面毛多 |