css代码
#Snow{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 99999;
background: rgba(0, 191, 255,0.4);
pointer-events: none;
}
JavaScript代码
/雪花Start/
(function() {
var canvas = document.createElement(‘canvas’);
document.body.appendChild(canvas);
canvas.id=‘Snow’;
//
var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60);
};
window.requestAnimationFrame = requestAnimationFrame;
})();
(function() {
var flakes = [],
canvas = document.getElementById(“Snow”), //画布ID,与上一步创建的画布对应
ctx = canvas.getContext(“2d”),