2024-01-03 18:32:45 +00:00
|
|
|
console.log("winter");
|
|
|
|
|
|
|
|
const snowContent = ['❄', '❅', '❆']
|
|
|
|
const snowflake = '● '
|
|
|
|
const snowContainer = document.getElementById('winter');
|
|
|
|
|
|
|
|
const random = (num) => {
|
|
|
|
return Math.floor(Math.random() * num);
|
|
|
|
}
|
|
|
|
|
|
|
|
const getRandomStyles = () => {
|
|
|
|
const top = random(100);
|
|
|
|
const left = random(100);
|
|
|
|
const dur = random(10) + 10;
|
|
|
|
const size = random(15) + 15;
|
|
|
|
return `
|
|
|
|
top: -${top}%;
|
|
|
|
left: ${left}%;
|
|
|
|
font-size: ${size}px;
|
|
|
|
animation-duration: ${dur}s;
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
const createSnow = (num) => {
|
|
|
|
for (var i = num; i > 0; i--) {
|
|
|
|
var snow = document.createElement("div");
|
|
|
|
snow.className = "snow";
|
|
|
|
snow.style.cssText = getRandomStyles();
|
2024-01-07 22:38:00 +00:00
|
|
|
snow.innerHTML = snowflake;
|
2024-01-03 18:32:45 +00:00
|
|
|
// snow.innerHTML = snowflake;
|
|
|
|
snowContainer.append(snow);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
window.addEventListener("load", () => {
|
|
|
|
createSnow(30)
|
|
|
|
});
|