html借助marquee實(shí)現(xiàn)文字左右滾動(dòng)
來(lái)源:懂視網(wǎng)
責(zé)編:小采
時(shí)間:2020-11-27 14:44:23
html借助marquee實(shí)現(xiàn)文字左右滾動(dòng)
html借助marquee實(shí)現(xiàn)文字左右滾動(dòng):代碼如下:<BODY>//借助于marquee<MARQUEE behavior=scroll contenteditable=true onstart=this.firstChild.innerHTML+=this.firstChild.innerHTML; scrollamount=3 width=100&g
導(dǎo)讀html借助marquee實(shí)現(xiàn)文字左右滾動(dòng):代碼如下:<BODY>//借助于marquee<MARQUEE behavior=scroll contenteditable=true onstart=this.firstChild.innerHTML+=this.firstChild.innerHTML; scrollamount=3 width=100&g

代碼如下:
<BODY>
//借助于marquee
<MARQUEE behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100">
<SPAN unselectable="on">這里是要滾動(dòng)的內(nèi)容</SPAN>
</MARQUEE>
//普通的實(shí)現(xiàn)方法
<DIV id="scrollobj" style="white-space:nowrap;overflow:hidden;width:500px;">
<span>這里是要滾動(dòng)的內(nèi)容</span>
</DIV>
<script language="javascript" type="text/javascript">
function scroll(obj) {
var tmp = (obj.scrollLeft)++;
//當(dāng)滾動(dòng)條到達(dá)右邊頂端時(shí)
if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML;
//當(dāng)滾動(dòng)條滾動(dòng)了初始內(nèi)容的寬度時(shí)滾動(dòng)條回到最左端
if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0;
}
setInterval("scroll(document.getElementById('scrollobj'))",20);
</script>
</BODY>
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
html借助marquee實(shí)現(xiàn)文字左右滾動(dòng)
html借助marquee實(shí)現(xiàn)文字左右滾動(dòng):代碼如下:<BODY>//借助于marquee<MARQUEE behavior=scroll contenteditable=true onstart=this.firstChild.innerHTML+=this.firstChild.innerHTML; scrollamount=3 width=100&g