<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> *{ margin: 0; padding: 0; } #div1,#div2{ position: absolute; left: 0; top: 0; } #div2{ color: red; width: 15px; height: 18px; overflow: hidden; } #div2 span{ position: absolute; left: 0; top: 0; width: 2000px; } </style> <script> window.onload=function(){ var oDiv2=document.getElementById("div2"); var oSpan2=oDiv2.getElementsByTagName("span")[0]; setInterval(function(){ oDiv2.style.left=oDiv2.offsetLeft+1+"px"; oSpan2.style.left=-oDiv2.offsetLeft+"px"; },30) } </script> </head> <body> <div id="div1"> <span>首轮中央环保督察列入地方整改方案的2147个问题,近70%已解决</span> </div> <div id="div2"> <span>首轮中央环保督察列入地方整改方案的2147个问题,近70%已解决</span> </div> </body> </html>