久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

原生js實現(xiàn)焦點輪播圖效果-創(chuàng)新互聯(lián)

原生js焦點輪播圖主要注意這幾點:

成都創(chuàng)新互聯(lián)是一家專注于成都網(wǎng)站建設、成都做網(wǎng)站與策劃設計,貴池網(wǎng)站建設哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設十多年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:貴池等地區(qū)。貴池做網(wǎng)站價格咨詢:13518219792

1、前后按鈕實現(xiàn)切換,同時注意輔助圖

2、中間的button隨著前后按鈕對應切換,同時按button也能跳轉(zhuǎn)到相應的index

3、間隔調(diào)用與無限輪播。

4、注意在動畫時要停止按鈕,或者說上一個動畫完畢下一個動畫才能執(zhí)行

5、另外在切換圖片的時候,底部的Button動畫效果,是從底部開始往上升的,要用到transform:scale()和transform-origin:0 100%兩個轉(zhuǎn)換屬性,代碼如下

<!DOCTYPE html>
<html>
 <head>
 <meta charset="utf-8"/>
 <meta name="viewpoint" content="width=device-width,initial-scale=1,user-scalable="no">
 <title>20170101</title>
 <style type="text/css">
 a{text-decoration:none;color:#3DBBF5;}
 .wrapper{width:750px;height:350px;background:#001032;margin:20px auto;text-align:center;box-shadow:0 0 12px 2px hsla(0,20%,30%,0.5);padding:10px 15px;position:relative;}
 .effect{position:relative;cursor:pointer;}
 .effect:hover{color:#02a0e9;}
 .effect:before{width:100%;display:inline-block !important;position:absolute;height:1px;background:#02a0e9;transition:all 0.4s ease-in-out;-webkit-transition:all 0.4s ease-in-out;-moz-transition:all 0.4s ease-in-out;transform:scale(0,1);content:'';bottom:-5px;left:0;}
 .effect:hover:before{transform:scale(1);-webkit-transform:scale(1);}
 #lunBo{margin-top:20px;overflow:hidden;height:300px;width:750px;position:relative;}
 #list{position:absolute;z-index:22;height:300px;width:5250px;}
 #list img{float:left;}
 #buttons { position: absolute; height: 20px; width: 150px; z-index: 99; bottom: 20px; left: 40%;}
    span { cursor: pointer; float: left; width: 10px; height: 5px; background: #333; margin-right: 10px;}
     .on { background: yellow;transition:all 0.4s ease-in-out;-webkit-transition:all 0.4s ease-in-out;-moz-transition:all 0.4s ease-in-out;transform:scale(1,4);-ms-transform:scale(1,4);-moz-transform:scale(1,4);-webkit-transform:scale(1,4);transform-origin:0% 0%;-webkit-transform-origin:0% 100%;-moz-transform-origin:0% 100%;}
  .arrow { cursor: pointer; display: none; line-height: 39px; text-align: center; font-size: 36px; font-weight: bold; width: 40px; height: 100px; line-height:100px;position: absolute; z-index: 92; top: 30%; background-color: RGBA(0,0,0,.3); color: #fff;}
    .arrow:hover { background-color: RGBA(0,0,0,.7);}
    #lunBo:hover .arrow { display: block;}
    #prev { left: 0px;}
    #next { right: 0px;}
 </style>
 </head>
 <body>
 <div class="wrapper">
  <a class="effect" href="#">2016完了,2017來了</a>
  <div id="lunBo">
  <div id="list" >
   <img src="/upload/otherpic2/78130.jpg" alt=""/>
   <img src="/upload/otherpic2/78131.jpg" alt=""/>
   <img src="/upload/otherpic2/78132.jpg" alt=""/>
   <img src="/upload/otherpic2/78133.jpg" alt=""/>
   <img src="/upload/otherpic2/78134.jpg" alt=""/>
   <img src="/upload/otherpic2/78130.jpg" alt=""/>
   <img src="/upload/otherpic2/78131.jpg" alt=""/>
  </div>
  <div id="buttons">
   <span index="1" class="on"></span>
   <span index="2"></span>
   <span index="3"></span>
   <span index="4"></span>
   <span index="5"></span>
  </div>
  <a href="javascript:;" id="prev" class="arrow">&lt;</a>
  <a href="javascript:;" id="next" class="arrow">&gt;</a>
  </div>
 </div>
 <script>
 window.onload = function(){
  var lunBo = document.getElementById('lunBo');
  var list = document.getElementById('list');
  var buttons = document.getElementById('buttons').getElementsByTagName('span');
  //console.log(buttons);
  var prev = document.getElementById('prev');
      var next = document.getElementById('next');
  var index = 1;
  var animated = false;
  var interval = 3000;
  var timer;
  //顯示按鈕的索引
  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 == 5) {
          index = 1;
        }
        else {
          index += 1;
        }
        animate(-750);
        showButton();
      };
      prev.onclick = function () {
        if (animated) {
          return;
        }
        if (index == 1) {
          index = 5;
        }
        else {
          index -= 1;
        }
        animate(750);
        showButton();
      };
  //parseInt()轉(zhuǎn)換為純數(shù)值
  function animate(offset){
  animated = true;
  var newLeft = parseInt(list.style.left) + offset; //目標值
  var time = 300; //位移總時間為300
  var interval = 10; //
  var speed = offset/(Math.floor(time/interval)); //每次位移量
  function go(){
  if( (speed < 0 && parseInt(list.style.left) > newLeft) || ( speed > 0 && parseInt(list.style.left) < newLeft) ){
   list.style.left = parseInt(list.style.left) + speed + 'px';
    setTimeout(go,interval);
  }else{
   animated = false;
   list.style.left = newLeft+ 'px';  //現(xiàn)在的位移
   if( newLeft > -750){           //假的輔助圖
   list.style.left = -3750 + 'px';
   }
   if( newLeft < -3750){
   list.style.left = -750 + 'px';
   }
  }
  };
  go();  
  };
  //小按鈕
  for(var i=0;i < buttons.length;i++){
  buttons[i].onclick = function(){

  if(this.className == 'on'){
   return;
  };
   var myIndex = parseInt(this.getAttribute('index'));
   var offset = -750 * (myIndex - index);

   animate(offset);
          index = myIndex;
          showButton();
  }
  }
  lunBo.onmouseout = play;
  lunBo.onmouseover = stop;
  play();
 }
 </script>
 </body>
</html>

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

當前標題:原生js實現(xiàn)焦點輪播圖效果-創(chuàng)新互聯(lián)
本文地址:http://sd-ha.com/article48/jjghp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供關鍵詞優(yōu)化、網(wǎng)站維護ChatGPT、定制開發(fā)面包屑導航、App開發(fā)

廣告

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

網(wǎng)站建設網(wǎng)站維護公司