css:
<style>
*{
padding:0px;
margin:0px
}
#main{
width:1000px;
height:600px;
}
.div{
width:20px;
line-height:0px
}
</style>
jQuery:
<script>
$(function(){
var i=1;
var zd;
function show(){
clearTimeout(a);
var zm=parseInt(Math.random()*25);
zd=String.fromCharCode(zm+65);
var wy=Math.random()*500;//设置偏移量
var a=setTimeout(show,1000);
$("#main").append($("<div class='div' name='"+zd+"' id='a"+i+"'>"+zd+"</div>"));
$("div[id='a"+i+++"']").offset({ top: 0, left: wy}).animate({top:600},10000,function() {
$(this).remove();
});
}show();
$(window).keydown(function(event){
var value=event.keyCode;
var re=String.fromCharCode(value);
if(re!=null){
$("div[name='"+re+"']").remove();
}
});
})
</script>
不加line-height:0px,会导致字母消失时,其他的字母向上回升