* {
margin:0
padding:0
}
body {
background:black
overflow:hidden
}
.container {
width:20px
height:60px
position:absolute
}
.nav {
height:20px
width:20px
display:block
margin-top:12px
border-radius:10px
background:#33ccff
opacity:0.8
background: url(1.jpg) no-repeat center
background-size: auto 100%
}
</style>
<script>
$(function() {
var w = window.screen.width
var h = window.screen.height
var count = 0
var drop = function() {
this.v = Math.random() * 1 + 0.5
this.left = Math.random() * w
}
drop.prototype = {
constructor: drop,
create: function() {
count++
var $drop = $('<div class="container"><span class="nav"></span></div>')
$drop.appendTo('body')
},
addCss: function() {
$('.container:last').css({
left: this.left + 'px'
})
},
dropEvent: function() {
var time = Math.floor(h / this.v)//下降速度
$('.container:last').animate({
top: h + 'px',
opacity: '1'
}, time)
}
}
function updata() {
if(count >200) {
for(var i = 0i <100i++) {
$('div:first').remove()
}
count = 0
}
}
setInterval(function() {
var Drop = new drop()
Drop.create()
Drop.addCss()
Drop.dropEvent()
updata()
}, 50)
})
</script>
第一步:把<body>改为: <body bgcolor=#000000" onLoad="snow()">第二步:加入
<script language="JavaScript">
<!--
N = 40
Y = new Array()
X = new Array()
S = new Array()
A = new Array()
B = new Array()
M = new Array()
V = (document.layers)?1:0iH=(document.layers)?window.innerHeight:window.document.body.clientHeight
iW=(document.layers)?window.innerWidth:window.document.body.clientWidth
for (i=0i <Ni++){
Y[i]=Math.round(Math.random()*iH)
X[i]=Math.round(Math.random()*iW)
S[i]=Math.round(Math.random()*5+2)
A[i]=0
B[i]=Math.random()*0.1+0.1
M[i]=Math.round(Math.random()*1+1)
}
if (V){
for (i = 0i <Ni++)
{document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")}
}
else{
document.write('<div style="position:absolutetop:0pxleft:0px">')
document.write('<div style="position:relative">')
for (i = 0i <Ni++)
{document.write('<div id="si" style="position:absolutetop:0left:0width:'+M[i]+'height:'+M[i]+'background:#fffff0font-size:'+M[i]+'"></div>')}
document.write('</div></div>')
}
function snow(){
var H=(document.layers)?window.innerHeight:window.document.body.clientHeight
var W=(document.layers)?window.innerWidth:window.document.body.clientWidth
var T=(document.layers)?window.pageYOffset:document.body.scrollTop
var L=(document.layers)?window.pageXOffset:document.body.scrollLeft
for (i=0i <Ni++){
sy=S[i]*Math.sin(90*Math.PI/180)
sx=S[i]*Math.cos(A[i])
Y[i]+=sy
X[i]+=sx
if (Y[i] >H){
Y[i]=-10
X[i]=Math.round(Math.random()*W)
M[i]=Math.round(Math.random()*1+1)
S[i]=Math.round(Math.random()*5+2)
}
if (V){document.layers['sn'+i].left=X[i]document.layers['sn'+i].top=Y[i]+T}
else{si[i].style.pixelLeft=X[i]si[i].style.pixelTop=Y[i]+T}
A[i]+=B[i]
}
setTimeout('snow()',10)
}
//-->
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)