不需要用js. <marquee direction="down" scrollamount="3">文字</marquee>
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;}
不知道是不是这样的