js實現無縫迴圈滾動,js無縫滾動

來源:互聯網
上載者:User

js實現無縫迴圈滾動,js無縫滾動

本文執行個體為大家分享了js無縫迴圈滾動實現代碼,供大家參考,具體內容如下

1、圖片格式:260*400.
2、使用迴圈定時器輕鬆實現

<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>無縫滾動</title></head><style type="text/css"> .row{  width: 1298px;  height: 400px;  border: 1px solid;  box-shadow:2px 2px 2px #000;  overflow: hidden; } .box{  position: relative; } .box1,.box2{  width: 1298px;  position: absolute; } .box2{  left:1298px; } img{  float: left; }</style><body> <div class="row">  <div class="box" id="box">   <div class="box1" id="box1">    <img src="images/1.jpg">    <img src="images/2.jpg">    <img src="images/3.jpg">    <img src="images/4.jpg">    <img src="images/5.jpg">   </div>   <div class="box2" id="box2">    <img src="images/1.jpg">    <img src="images/2.jpg">    <img src="images/3.jpg">    <img src="images/4.jpg">    <img src="images/5.jpg">   </div>  </div> </div></body><script type="text/javascript"> window.onload = function(){  var _box1 = document.getElementById("box1");  var _box2 = document.getElementById("box2");  var x = 0;  var fun = function(){   _box1.style.left = x + 'px';   _box2.style.left = (x +1298) + 'px';   x--;   if((x +1298) == 0){    x = 0;   }  }  setInterval(fun,1); }</script></html>

以上就是本文的全部內容,希望對大家的學習有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.