* {
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>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)