1.html原生方法
<marquee>123123</marquee>
2.定时器方法
let paymentPromptText = document.getElementById('paymentPromptText'); // 文本的总宽度 const textWidth=paymentPromptText.scrollWidth let size=0 paymentPromptText.style.left='100px' const crollingst=function(){ if(size==0-textWidth){ size=1090 }else{ size-- } paymentPromptText.style.left=size+'px' setTimeout(() => { crollingst() }, 10); } crollingst()
<div id="paymentPromptText">123123123_—————————————————————————————————————</div>
#paymentPromptText{ /* width: 100%; */ position: relative; left: 0px; }
标签:vue,const,crollingst,js,paymentPromptText,跑马灯,left,size From: https://www.cnblogs.com/naitang/p/16918261.html