中文字幕第五页-中文字幕第页-中文字幕韩国-中文字幕最新-国产尤物二区三区在线观看-国产尤物福利视频一区二区

JS+HTML+CSS怎么實(shí)現(xiàn)輪播效果-創(chuàng)新互聯(lián)

小編給大家分享一下JS+HTML+CSS怎么實(shí)現(xiàn)輪播效果,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

成都創(chuàng)新互聯(lián)主要從事成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)綿竹,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792

具體內(nèi)容如下

1.lunbo.html代碼:

<!DOCTYPE html> 
<html lang="en"> 
<head> 
  <meta charset="UTF-8"> 
  <title>大輪播</title> 
  <link rel="stylesheet" type="text/css" href="CSS/lunbo.css"/> 
  <script src="JS/lunbo.js" type="text/javascript"></script> 
</head> 
 
<body> 
<div id="container"> 
  <div id="list" > 
    <img src="image/banner_3.jpg"/> 
    <img src="image/banner_1.jpg"/> 
    <img src="image/banner_2.jpg"/> 
    <img src="image/banner_3.jpg"> 
    <img src="image/banner_1.jpg"/></div> 
  <div id="buttons"> 
    <span index="1"></span> 
    <span index="2"></span> 
    <span index="3"></span> 
  </div> 
  <a href="javascript:;" id="prev" class="arrow" ><</a> 
  <a href="javascript:;" id="next" class="arrow" >></a></div> 
</body> 
 
</html>

2.CSS/lunbo.css代碼:

body { 
  margin: 0px; 
  padding: 0px; 
  width: 1350px; 
  height: 618px; 
} 
 
a { 
  text-decoration: none; 
} 
 
#container { 
  width: 1350px; 
  height: 618px; 
  overflow: hidden; 
  position: relative; 
  border-top: 1px solid #ac6a0a; 
} 
 
#list { 
  width: 6750px; 
  height: 618px; 
  position: absolute; 
  z-index: 1; 
} 
 
#list img { 
  float: left; 
  width: 1350px; 
  height: 618px; 
} 
 
#buttons { 
  position: absolute; 
  height: 20px; 
  width: 60px; 
  z-index: 2; 
  bottom: 20px; 
  left: 50%; 
} 
 
#buttons span { 
  cursor: pointer; 
  float: left; 
  border: 1px solid #ad6a0a; 
  width: 10px; 
  height: 10px; 
  -webkit-border-radius: 50%; 
  -moz-border-radius: 50%; 
  border-radius: 50%; 
  margin-right: 5px; 
} 
 
#buttons .on { 
  background: orangered; 
} 
 
.arrow { 
  cursor: pointer; 
  display: none; 
  line-height: 100px; 
  text-align: center; 
  width: 40px; 
  height: 40px; 
  position: absolute; 
  z-index: 2; 
  top: 180px; 
  background-color: RGBA(0, 0, 0, 0); 
  color: #fff; 
} 
 
.arrow:hover { 
  background-color: RGBA(0, 0, 0, 0); 
} 
 
#container:hover .arrow { 
  display: block; 
} 
 
#prev { 
  left: 10px; 
  color: #ffffff; 
} 
 
#next { 
  right: 10px; 
  color: #ffffff; 
}

3.JS/lunbo.js代碼:

window.onload = function () { 
  var container = document.getElementById('container'); 
  var list = document.getElementById('list'); 
  var buttons = document.getElementById('buttons').getElementsByTagName('span'); 
  var prev = document.getElementById('prev'); 
  var next = document.getElementById('next'); 
  var index = 1; 
  var len = 3; 
  var animated = false; 
  var interval = 3000; 
  var timer; 
  var size = 1350; 
 
  function animate(offset) { 
    if (offset == 0) { 
      return; 
    } 
    animated = true; 
    var time = 300; 
    var inteval = 10; 
    var speed = offset / (time / inteval); 
    console.log("speed:" + speed); 
    var left = parseInt(list.style.left) + offset; 
 
    var go = function () { 
      if ((speed > 0 && parseInt(list.style.left) < left) || (speed < 0 && parseInt(list.style.left) > left)) { 
        list.style.left = parseInt(list.style.left) + speed + 'px'; 
        console.log(list.style.left); 
        setTimeout(go, inteval); 
      } else { 
        list.style.left = left + 'px'; 
        if (left > -200) { 
          list.style.left = -size * len + 'px'; 
        } 
        if (left < ( -size * len)) { 
          list.style.left = '-' + size + 'px'; 
        } 
        animated = false; 
        console.log("left:" + list.style.left); 
      } 
    } 
    go(); 
  } 
 
  function showButton() { 
    for (var i = 0; i < buttons.length; i++) { 
      if (buttons[i].className == 'on') { 
        buttons[i].className = ''; 
        break; 
      } 
    } 
    buttons[index - 1].className = 'on'; 
  } 
 
  function play() { 
    timer = setTimeout(function () { 
        next.onclick(); 
        play(); 
      }, 
      interval); 
  } 
 
  function stop() { 
    clearTimeout(timer); 
  } 
 
  next.onclick = function () { 
    if (animated) { 
      return; 
    } 
    if (index == len) { 
      index = 1; 
    } else { 
      index += 1; 
    } 
    animate(-size); 
    showButton(); 
  } 
  prev.onclick = function () { 
    if (animated) { 
      return; 
    } 
    if (index == 1) { 
      index = len; 
    } else { 
      index -= 1; 
    } 
    animate(size); 
    showButton(); 
  } 
  for (var i = 0; i < buttons.length; i++) { 
    buttons[i].onclick = function () { 
      if (animated) { 
        return; 
      } 
      if (this.className == 'on') { 
        return; 
      } 
      var myIndex = parseInt(this.getAttribute('index')); 
      var offset = -size * (myIndex - index); 
 
      animate(offset); 
      index = myIndex; 
      showButton(); 
    } 
  } 
  container.onmouseover = stop; 
  container.onmouseout = play; 
  play(); 
};

看完了這篇文章,相信你對(duì)“JS+HTML+CSS怎么實(shí)現(xiàn)輪播效果”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道,感謝各位的閱讀!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

本文標(biāo)題:JS+HTML+CSS怎么實(shí)現(xiàn)輪播效果-創(chuàng)新互聯(lián)
文章源于:http://m.2m8n56k.cn/article8/dhhpip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)建站公司品牌網(wǎng)站建設(shè)網(wǎng)站制作全網(wǎng)營銷推廣品牌網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
主站蜘蛛池模板: 在线免费观看一区二区三区 | 成人国产精品视频 | 性生大片一级毛片免费观看 | 国产免费久久精品 | 久久综合精品视频 | 三级黄色在线播放 | 国产亚洲精品久久久久久午夜 | aaa在线观看高清免费 | 久热国产在线视频 | 欧美一级精品 | 久久久国产一区二区三区丝袜 | 欧美成人在线影院 | 欧美成人一级片 | 亚洲欧美视频一区二区三区 | 亚洲国产欧美在线不卡中文 | 中国一级毛片视频 | 欧美亚洲影院 | 亚洲国产精品67194成人 | 普通话对白国产情侣自啪 | 久久免费视频2 | 国产精品免费一级在线观看 | 久久er热这里只有精品免费 | 欧美 亚洲 丝袜 清纯 中文 | 夜色成人免费观看 | 国产一级在线观看www色 | 成人手机在线 | 亚洲美女自拍视频 | 久久亚洲私人国产精品va | 曰韩美女一级视频 | 日韩国产精品99久久久久久 | 国产精品久久久久久久久99热 | 国产l精品国产亚洲区久久 国产tv在线 | 在线成人a毛片免费播放 | 成人看片黄a免费看视频 | 久久a级片 | 久久五| 7777视频| 欧美在线三级 | 日本不卡高清免费 | 手机看片毛片 | 精品久久久久久久久免费影院 |