【发布时间】:2013-12-17 01:05:12
【问题描述】:
这个 sn-p 创建雪花效果,我一直在玩它试图获得不同大小的雪花,但到目前为止只能让它们在页面刷新时改变大小,我真正想要的是每个雪花是不同的尺寸,(或至少有 2 或 3 种不同的尺寸)有什么帮助吗?
var snowCount = 0,
fs = Math.floor(Math.random() * (30 - 20) + 20);
function snowFlakes(){
var randomTime = Math.floor(Math.random() * (500) * 2);
setTimeout(function(){
snowCount = snowCount +2;
jquerysnow();
snowFlakes();
},randomTime);
}
function jquerysnow() {
var snow = $('<div class="snow" style="font-size:'+fs+'px;"></div>'),
dH = $(document).height() + 'px',
sf = $('#snowflakes');
sf.prepend(snow);
snowX = Math.floor(Math.random() * sf.width());
snowSpd = Math.floor(Math.random() * (500) * 20);
snow.css({'left':snowX+'px'});
snow.html('❄');
snow.animate({top : dH, opacity : '1',}, 9000, function(){
$(this).remove();
});
}
snowFlakes();
【问题讨论】: