首页 新闻 会员 周边

如何用js实现文字向下滚动

0
悬赏园豆:5 [待解决问题]

如何用js实现文字向下滚动,而且在任何浏览器中都能运行

午后の時間的主页 午后の時間 | 初学一级 | 园豆:197
提问于:2012-11-15 15:17
< >
分享
所有回答(3)
0
chenping2008 | 园豆:9836 (大侠五级) | 2012-11-15 17:18
0

不需要用js. <marquee direction="down" scrollamount="3">文字</marquee>

三十三块 | 园豆:373 (菜鸟二级) | 2012-11-15 18:56
0
 var TheMatrix = {
     height : window.screen.height,    //浏览器高
     width : window.screen.width,    //浏览器宽
     speed : 35,    //下降速度
     createDIV : function(){    //生成div
                     var div = document.createElement("div");
                     var posy = 0;
                     div.style.left = Math.round(Math.random()*TheMatrix.width) +"px";
                     div.style.fontSize = Math.round(Math.random()*50) +"px";
                     div.style.opacity = Math.random().toFixed(1);
                     div.innerHTML = Math.round(Math.random()*100000000000000000);
                     document.body.appendChild(div);
                     var moveDIV = setInterval(function(){
                         //alert(posy);
                         div.innerHTML =  Math.round(Math.random()*100000000000000000);
                         div.style.top =  posy - TheMatrix.height + "px";
                         posy += TheMatrix.speed;
                         if(parseInt(div.style.top) > TheMatrix.height){                
                             document.body.removeChild(div);
                             clearInterval(moveDIV);
                         }            
                     }, 20);
     }
 }
 setInterval("TheMatrix.createDIV()",50)

CSS样式:

body{background-color: #000;margin:0;padding:0;font-family:Arial;color: #008800;line-height: 0.9;overflow: hidden;}
div{width: 5px;word-wrap:break-word;position: absolute;}

不知道是不是这样的

最佳损友。 | 园豆:63 (初学一级) | 2012-12-10 14:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册