请问这个无缝滚动怎么实现往右边滚动

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>无缝滚动</title>

<style>

*{

margin:0;

padding: 0;

}

ul{

list-style: none;

}

img{

vertical-align: top;

}

.box{

width: 600px;

height: 200px;

background-color: red;

margin:100px auto;

position: relative;

overflow:hidden;

}

.box ul li{

float: left;

}

.box ul{

width: 400%;

position: absolute;

left: 0;

top: 0;

}

</style>

</head>

<body>

<div id="dome">

<ul>

<li><img src="./images/01.jpg"></li>

<li><img src="./images/02.jpg"></li>

<li><img src="./images/03.jpg"></li>

<li><img src="./images/04.jpg"></li>


<li><img src="./images/01.jpg"></li>

<li><img src="./images/02.jpg"></li>

</ul>

</div>

<script>

var dome = document.getElementById("dome");

var ul = dome.children[0];

var num = 0;

setInterval(fun,1);

function fun(){

num--;

if(num >= -1200 ){

ul.style.left = num + "px";

}

else{

ul.style.left = 0;

num = 0;                //这里为什么不是num--。让left重新走动呢

}

}

</script>

</body>

</html>


风轻云淡3582301
浏览 1370回答 3
3回答

发卡君

HTML不是很擅长啊
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript