<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <style> #demo { overflow:hidden; 820px; margin-left:8px; } #demo a {color:#00ff00; } #indemo { float: left; 1000%; height:100px; margin: 0 auto;} #demo1 { float: left; } #demo2 { float: left; } </style> </head> <body> <div id="demo"> <div id="indemo"> <div id="demo1"> <div> <a href="#" title="">【重磅通知】2020年社保缴费基数大调整!人社部消息,医保账户取消、五险变四险!</a> </div> </div> <div id="demo2"></div> </div> </div> <script type="text/javascript"> <!-- var speed=20; //数字越大速度越慢 var tab=document.getElementById("demo"); var tab1=document.getElementById("demo1"); var tab2=document.getElementById("demo2"); tab2.innerHTML=tab1.innerHTML; function Marquee(){ if(tab2.offsetWidth-tab.scrollLeft<=0) tab.scrollLeft-=tab1.offsetWidth else { tab.scrollLeft++; } } var MyMar=setInterval(Marquee,speed); //--> </script> </body> </html>