<svg class="svg-snowscene" xmlns="http://www.w3.org/2000/svg">
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
<circle />
</svg>
html {
height: 100%;
}
body {
height: 100%;
background-image:
linear-gradient(
to bottom in lch decreasing hue,
lch(36% 95 281) 0%,
lab(99% -148 -61) 100%
);
}
.svg-snowscene {
width: 100%;
height: 50%;
}
circle {
fill: #fff;
animation-name: snowing;
animation-duration: 3s;
animation-iteration-count: infinite;
animation-timing-function: ease-out;
&:nth-child(2n){
animation-delay: 1.5s;
}
&:nth-child(3n){
animation-delay: 2.3s;
animation-duration: 3.3s;
}
&:nth-child(4n){
animation-delay: 0.8s;
animation-duration: 3.2s;
}
&:nth-child(5n){
animation-delay: 2.8s;
}
}
@keyframes snowing {
0%{ fill-opacity: 1; }
100% {
fill-opacity: 0;
transform: translateY(100%);
}
}
View Compiled
const getRandom = (min, max) => {
return Math.random() * (max - min) + min;
}
const letItSnow = () => {
const snowflakes = document.querySelectorAll('circle');
snowflakes.forEach((snowflake) => {
snowflake.setAttribute('cx', getRandom(1,100) + '%');
snowflake.setAttribute('cy', '-' + getRandom(1,100));
snowflake.setAttribute('r', getRandom(1,3));
})
};
letItSnow();
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.