JS、CSS文字切換,定時交替,代碼精簡_文字特效

來源:互聯網
上載者:User
你可以把它看作像寫一般的CSS列表一樣,只用增加兩三行代碼就能完成轉場效果。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>文本定時變動代碼 </tITLE> <style type="text/css"> #newslist{ background:#f8f8f8;border:1px solid silver;padding:1px;height:20px;line-height:20px;width:288px; } #contain{ font-size:12px;overflow:hidden;list-style:none;width:288px;height:20px;margin:0px;padding:0; } #contain li{ height:22px;line-height:22px;white-space:nowrap;overflow:hidden; } </style> </hEAD> <BODY> <div id="newslist"> <ul id="contain"> <li>百度,世界最大的中文搜尋引擎</li> <li>CSDN,中國最聚人氣的IT技術社區</li> <li>雲棲社區</li> <li>播放器</li> </ul> </div> <SCRIPT LANGUAGE="JavaScript"> function xx(){ var container=document.getElementById("contain"); container.appendChild(container.firstChild); } setInterval("xx()",2000); </sCRIPT> </bODY> </hTML>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.