不用图片的jquery下雪效果

不用图片的jquery下雪效果1938
代码量很少,引用下jquery库,然后
<script>
$(function(){
  var wh=$(window).height();
  $(".snowbg").css("height",wh);

  var d="<div class='snow'>?<div>"
      setInterval(function(){
        var f=$(document).width();
        var e=Math.random()*f-100;//雪花的定位left值
        var o=0.3+Math.random();//雪花的透明度
        var fon=10+Math.random()*30;//雪花大小
        var l = e - 100 + 200 * Math.random();//雪花的横向位移
        var k=2000 + 5000 * Math.random();
        $(d).clone().appendTo(".snowbg").css({
          left:e+"px",
          opacity:o,
          "font-size":fon,
        }).animate({
          top:"400px",
          left:l+"px",
          opacity:0.1,
        },k,"linear",function(){$(this).remove()})
      },100)
})
</script>

也许你还喜欢