HTML代码:
<div id="contain"><div id="content">
作文,怎样才能写好?作文,好于勤读,作文,优于真情。作文一词,汇于欲要看究竟,处处细留心。作文于此,荟萃真情,如酒如烟,过于酿造。作文于新,纯于构思,百炼成钢.</div>
</div>
CSS代码:
#contain {width: 92%;height: 20px;position: relative;bottom: 24px;left: 20px;background-color: #fff;overflow: hidden;}#content {width: auto;height: 20px;white-space: nowrap;position: absolute;background-color:#fff ;
}
JS代码:
wid = contents.offsetWidth; //获取内容宽度
setInterval(animation, 20); //设置定时器
let move = 0;function animation() {move += 1;$('#content').css('margin-left', '-' + move + 'px');if (move > wid) {move = 344;}
}
ヾ(⌒∇⌒*)See You♪