欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js實現(xiàn)無縫循環(huán)滾動

 更新時間:2020年06月23日 17:30:00   作者:Mr.小Y  
這篇文章主要為大家詳細介紹了js實現(xiàn)無縫循環(huán)滾動的具體代碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了js無縫循環(huán)滾動實現(xiàn)代碼,供大家參考,具體內(nèi)容如下

1、圖片格式:260*400.
2、使用循環(huán)定時器輕松實現(xiàn)

<!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>

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評論