(function($) { $.fn.snow = function(options) { var $flake = $('<div id="flake" />').css({ 'position': 'absolute', 'top': '-50px' }).html('❄'), documentheight = $(document).height(), documentwidth = $(document).width(), defaults = { minsize: 10, maxsize: 20, newon: 2000, flakecolor: "red" }, options = $.extend({}, defaults, options); var interval = setinterval(function() { var startpositionleft = math.random() * documentwidth - 100, startopacity = 0.5 + math.random(), sizeflake = options.minsize + math.random() * options.maxsize, endpositiontop = documentheight - 40, endpositionleft = startpositionleft - 100 + math.random() * 200, durationfall = documentheight * 10 + math.random() * 5000; $flake.clone().appendto('body').css({ left: startpositionleft, opacity: startopacity, 'font-size': sizeflake, color: options.flakecolor }) .animate({ top: endpositiontop, left: endpositionleft, opacity: 0.2 }, durationfall, 'linear', function() { $(this).remove() }); }, options.newon); }; })(jquery); $.fn.snow({ minsize: 5, maxsize: 50, newon: 2000, flakecolor: 'red' });
如对本文有疑问, 点击进行留言回复!!
2020-07-21 html5如何监听veido的全屏 + css的字体间距 + JS的window.open() + 软技能svn与git
html+css+js适合前端小白的实战全解(超详细)——2048小游戏(二)
在使用@angular/cli创建的angular项目上添加postcss等一系列移动端自适应插件
网友评论