原生JS京東輪播圖代碼
更新時(shí)間:2017年03月22日 15:29:02 作者:Jensen_Yao
這篇文章主要為大家詳細(xì)介紹了原生JS京東輪播圖代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了JS輪播圖的具體代碼,供大家參考,具體內(nèi)容如下
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="css/reset.css" rel="external nofollow" /> <style> .jiantou { height: 36px; width: 24px; line-height: 36px; text-align: center; background-color: rgba(0, 0, 0, .3); font-size: 14px; color: #fff; position: absolute; top: 0; bottom: 0; margin: auto 0; display: none; z-index: 99999; cursor: pointer; } .left { left: 0; } .right { right: 0; } ul li { height: 20px; width: 20px; background-color: #B7B7B7; float: left; border-radius: 50%; margin: 2px; } ul { position: absolute; bottom: 15px; margin: 0 auto; background-color: rgba(255, 255, 255, .3); border-radius: 10px; left: 300px; z-index: 9999; cursor: pointer; } .on { background-color: #F40; } img { width: 790px; height: 340px; position: absolute; opacity: 0; /*transition: all 2s;*/ /*transition: all 0.5s;*/ /*時(shí)間給短一些*/ transition: opacity 0.5s; /*不要寫all 那么就不會(huì)影響到z-index*/ z-index: 0; } .in { width: 790px; height: 340px; } #out { width: 790px; height: 340px; margin: 100px auto; position: relative; } #out:hover .jiantou { display: block; } </style> </head> <body> <div id="out"> <div class="in"> <img src="img/j1.jpg" alt="" style="opacity: 1;z-index:1"/> <img src="img/j2.jpg" alt=""/> <img src="img/j3.jpg" alt=""/> <img src="img/j4.jpg" alt=""/> <img src="img/j5.jpg" alt=""/> <img src="img/j6.jpg" alt=""/> <img src="img/j7.jpg" alt=""/> <img src="img/j8.jpg" alt=""/> </div> <div class="left jiantou"><</div> <div class="right jiantou">></div> <ul class="clearFix"> <li class="on"></li> <li class="on"></li> <li class="on"></li> <li class="on"></li> <li class="on"></li> <li class="on"></li> <li class="on"></li> <li class="on"></li> </ul> </div> <script> var out = document.getElementById("out"); var img = document.images; var left = document.getElementsByClassName("left").item(0); var right = document.getElementsByClassName("right").item(0); var lilist = document.getElementsByTagName("li"); var index = 0;//標(biāo)識(shí)哪張圖片正在出現(xiàn) var timer = null; var timer1 = null; right.onclick = function () { //把所有人的opacity置為0 /*for (var i = 0; i < img.length; i++) { img[i].style.opacity = 0; }*/ img[index].style.opacity = 0; img[index].style.zIndex = 0; lilist[index].className = ''; // index++; index == 7 ? index = 0 : index++; lilist[index].className = 'on'; img[index].style.opacity = 1; img[index].style.zIndex = 1; }; left.onclick = function () { img[index].style.opacity = 0; lilist[index].className = ''; img[index].style.zIndex = 0; // index--; index == 0 ? index = 7 : index--; lilist[index].className = 'on'; img[index].style.opacity = 1; img[index].style.zIndex = 1; }; for (var i = 0; i < lilist.length; i++) { lilist[i].value = i; lilist[i].onmouseover = function () { var that = this; timer=setTimeout(function () { img[index].style.opacity = 0; lilist[index].className = ''; img[index].style.zIndex = 0; index = that.value; lilist[index].className = 'on'; img[index].style.opacity = 1; img[index].style.zIndex = 1; },300) }; lilist[i].onmouseout = function () { clearTimeout(timer); } } out.onclick = function (e) { console.log(e.target); }; timer1 = setInterval(right.onclick,2000); out.onmouseover = function () { clearInterval(timer1); }; out.onmouseout = function () { timer1 = setInterval(right.onclick, 2000); }; var num =5 var arr = []; var img =document.images; for(var i=0;i<img.length;i++){ if(i<5){ arr.push(img[i].offsetHeight); }else { img[i].style.position='abl' } } </script> </body> </html>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 原生js實(shí)現(xiàn)輪播圖的示例代碼
- 原生js實(shí)現(xiàn)無限循環(huán)輪播圖效果
- 原生js實(shí)現(xiàn)移動(dòng)開發(fā)輪播圖、相冊(cè)滑動(dòng)特效
- 原生js實(shí)現(xiàn)無縫輪播圖效果
- 原生js實(shí)現(xiàn)旋轉(zhuǎn)木馬輪播圖效果
- 原生JS實(shí)現(xiàn)層疊輪播圖
- 原生JS輪播圖插件
- 原生js實(shí)現(xiàn)網(wǎng)易輪播圖效果
- 原生js實(shí)現(xiàn)焦點(diǎn)輪播圖效果
- 無限循環(huán)輪播圖之運(yùn)動(dòng)框架(原生JS實(shí)現(xiàn))
- 原生JS實(shí)現(xiàn)的輪播圖功能詳解
相關(guān)文章
js控制按鈕,防止頻繁點(diǎn)擊響應(yīng)的實(shí)例
下面小編就為大家?guī)硪黄猨s控制按鈕,防止頻繁點(diǎn)擊響應(yīng)的實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-02-02深入了解JavaScript中邏輯賦值運(yùn)算符的應(yīng)用
邏輯賦值是對(duì)現(xiàn)有數(shù)學(xué)和二進(jìn)制邏輯運(yùn)算符的擴(kuò)展。我們先復(fù)習(xí)一下,然后看看把它們結(jié)合在一起能得到什么,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2022-11-11js 數(shù)組倒序排列的具體實(shí)現(xiàn)
有時(shí)候需要將數(shù)組類型變量內(nèi)的元素顛倒一下順序再輸出,本文就詳細(xì)的介紹一下,具有一定的參考價(jià)值,感興趣的可以了解一下2023-08-08json數(shù)據(jù)處理及數(shù)據(jù)綁定
本文主要介紹了json數(shù)據(jù)處理及數(shù)據(jù)綁定的相關(guān)知識(shí)。具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-01-01JavaScript模運(yùn)算符理解及運(yùn)用實(shí)戰(zhàn)
這篇博客文章是為初級(jí)到中級(jí)JavaScript開發(fā)人員所寫,主要為大家介紹了JavaScript模運(yùn)算符理解及運(yùn)用實(shí)戰(zhàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步2023-11-11在VS?Code中使用Snippet?Craft擴(kuò)展提高編碼效率的過程詳解
這篇文章主要介紹了在VS?Code中使用Snippet?Craft擴(kuò)展提高編碼效率,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2024-08-08