這篇文章主要應用javascript代碼實現文字垂直滾動的效果,需要的朋友可以參考下
在大型的網站新聞公告和友情鏈接等領域經常有這種文字或圖片垂直滾動的效果,下面就介紹一下文字垂直滾動的javascript代碼。
javascript代碼如下:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="author" content="http://www.companysz.com/" />
- <title>武林網</title>
- <style>
- a {
- display:block;
- font-size:15px;
- line-height:18px;
- text-decoration:none;
- color:#333;
- font-family:Arial;
- font-size:12px;
- }
- .main{
- background:no-repeat 4px 5px;
- border:1px solid #aaa;
- width:400px;
- padding:3px 2px 2px 20px;
- }
- #thediv{
- height:36px;
- overflow:hidden;
- }
- </style>
- <script type="text/javascript">
- var c, _ = Function;
- window.onload=function(){
- with (o = document.getElementById("thediv")){
- innerHTML += innerHTML; onmouseover = _("c=1"); onmouseout = _("c=0");
- }
- (F=_("if(#%18||!c)#++,#%=o.scrollHeight>>1;setTimeout(F,#%18?10:3000);".replace(/#/g,"o.scrollTop")))();
- }
- </script>
- </head>
- <body>
- <div class="main">
- <div id="thediv">
- <a>螞蟻部落歡迎您</a>
- <a>只有奮斗才會有好的結果</a>
- <a>高手都是從菜鳥成長而來</a>
- <a>太陽馬上就要出來了</a>
- </div>
- </div>
- </body>
- </html>
以上代碼就實現了文字垂直滾動的效果,文字可有上下間歇性的滾動,有需要的朋友可以來參考下,希望大家喜歡。
新聞熱點
疑難解答
圖片精選