Below is an all-in-one HTML file that creates four weather cards arranged side by side (each with a dark background). A set of buttons lets you switch the animation on all cards between Wind, Rain, Sun, and . You can simply save the code as an HTML file and open it in your browser.
────────────────────────────────────────────────────────────────────
htmlCopy
How It Works
HTML Structure: (each containing an.animation-area) are arranged side by side inside a.cards-container. Below, a set of buttons calls thesetWeather()function with the appropriate weather type.
CSS Animations:Wind:Two cloud elements move across the card using themoveCloudkeyframes.Rain:Multiple small raindrop divs fall from top to bottom using thefallanimation.Sun:A sun (yellow circle) pulses and eight rays radiate with a slight opacity pulse.Snow:Snowflakes fall slowly with thefallSnowkeyframes.
Wind:Two cloud elements move across the card using themoveCloudkeyframes.
Rain:Multiple small raindrop divs fall from top to bottom using thefallanimation.
Sun:A sun (yellow circle) pulses and eight rays radiate with a slight opacity pulse.
Snow:Snowflakes fall slowly with thefallSnowkeyframes.
JavaScript:ThesetWeatherfunction clears the animation area of each card and then populates it with the elements for the chosen weather condition by calling one of the four helper functions.
HTML Structure: (each containing an.animation-area) are arranged side by side inside a.cards-container. Below, a set of buttons calls thesetWeather()function with the appropriate weather type.
CSS Animations:
Wind:Two cloud elements move across the card using themoveCloudkeyframes.
Rain:Multiple small raindrop divs fall from top to bottom using thefallanimation.
Sun:A sun (yellow circle) pulses and eight rays radiate with a slight opacity pulse.
Snow:Snowflakes fall slowly with thefallSnowkeyframes.
Wind:Two cloud elements move across the card using themoveCloudkeyframes.
Rain:Multiple small raindrop divs fall from top to bottom using thefallanimation.
Sun:A sun (yellow circle) pulses and eight rays radiate with a slight opacity pulse.
Snow:Snowflakes fall slowly with thefallSnowkeyframes.
JavaScript:ThesetWeatherfunction clears the animation area of each card and then populates it with the elements for the chosen weather condition by calling one of the four helper functions.
Enjoy exploring the animations—and feel free to tweak the numbers, timings, or styles to suit your taste!