<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
.wrap{width:800pxheight:500pxmargin:200px auto 0position: relativeborder:1px solid #000overflow: hidden}
h1{position: absoluteleft:800pxword-break: keep-all}
</style>
<body>
<div class="wrap">
<h1>这是无缝滚动</h1>
<h1>这是无缝滚动</h1>
</div>
<script>
var wenzi=document.querySelectorAll("h1")
var speed1=0
var speed2=0
var flag=false
setInterval(function(){
speed1-=10
wenzi[0].style.left=800+speed1+"px"
wenzi[1].style.left=800+speed2+"px"
if(wenzi[0].offsetLeft==0){
flag=true
}
if(flag){
speed2-=10
}
if(wenzi[0].offsetLeft==0){
speed2=0
}
if(wenzi[1].offsetLeft==0){
speed1=0
}
},60)
</script>
</body>
</html>
纯手敲 觉得有用可以点个赞啊