console
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Animated Weather Cards</title>
<style>
body {
margin: 0;
padding: 20px;
background-color: #121212;
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
}
h1 {
color: #ffffff;
margin-bottom: 30px;
}
.weather-container {
display: flex;
gap: 20px;
flex-wrap: wrap;
justify-content: center;
}
.weather-card {
position: relative;
width: 250px;
height: 350px;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
background-color: #1e1e1e;
color: white;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 20px;
box-sizing: border-box;
}
.weather-icon {
font-size: 60px;
margin-top: 20px;
}
.temperature {
font-size: 48px;
font-weight: bold;
margin: 10px 0;
}
.condition {
font-size: 20px;
text-transform: uppercase;
letter-spacing: 2px;
margin-bottom: 20px;
}
.controls {
display: flex;
gap: 10px;
margin-top: 20px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #4a4a4a;
color: white;
cursor: pointer;
font-weight: bold;
transition: all 0.3s;
}
button:hover {
background-color: #6a6a6a;
}
button.active {
background-color: #2196F3;
}
.wind .weather-icon {
animation: sway 3s ease-in-out infinite alternate;
}
.wind-clouds {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
}
.wind-cloud {
position: absolute;
background-color: rgba(255, 255, 255, 0.2);
border-radius: 50%;
animation: float 8s ease-in-out infinite;
}
.wind-cloud:nth-child(1) {
width: 80px;
height: 40px;
top: 20%;
left: 10%;
animation-delay: 0s;
}
.wind-cloud:nth-child(2) {
width: 120px;
height: 60px;
top: 30%;
left: 40%;
animation-delay: 2s;
}
.wind-cloud:nth-child(3) {
width: 60px;
height: 30px;
top: 10%;
left: 70%;
animation-delay: 4s;
}
@keyframes float {
0%, 100% {
transform: translateX(0) translateY(0);
}
50% {
transform: translateX(20px) translateY(-10px);
}
}
@keyframes sway {
0%, 100% {
transform: rotate(-5deg);
}
50% {
transform: rotate(5deg);
}
}
.rain .weather-icon {
animation: pulse 2s infinite;
}
.rain-drops {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
overflow: hidden;
}
.rain-drop {
position: absolute;
background-color: rgba(173, 216, 230, 0.7);
width: 2px;
height: 20px;
border-radius: 50%;
animation: fall linear infinite;
}
@keyframes fall {
to {
transform: translateY(400px);
}
}
.sun .weather-icon {
animation: spin 8s linear infinite;
}
.sun-rays {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
}
.sun-ray {
position: absolute;
width: 2px;
height: 100px;
background: linear-gradient(to bottom, rgba(255, 215, 0, 0.8), transparent);
top: 20%;
left: 50%;
transform-origin: top center;
animation: pulse-ray 4s ease-in-out infinite;
}
.sun-ray:nth-child(1) {
transform: translateX(-50%) rotate(0deg);
}
.sun-ray:nth-child(2) {
transform: translateX(-50%) rotate(45deg);
animation-delay: 0.5s;
}
.sun-ray:nth-child(3) {
transform: translateX(-50%) rotate(90deg);
animation-delay: 1s;
}
.sun-ray:nth-child(4) {
transform: translateX(-50%) rotate(135deg);
animation-delay: 1.5s;
}
.sun-ray:nth-child(5) {
transform: translateX(-50%) rotate(180deg);
animation-delay: 2s;
}
.sun-ray:nth-child(6) {
transform: translateX(-50%) rotate(225deg);
animation-delay: 2.5s;
}
.sun-ray:nth-child(7) {
transform: translateX(-50%) rotate(270deg);
animation-delay: 3s;
}
.sun-ray:nth-child(8) {
transform: translateX(-50%) rotate(315deg);
animation-delay: 3.5s;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
@keyframes pulse-ray {
0%, 100% {
opacity: 0.3;
height: 80px;
}
50% {
opacity: 1;
height: 120px;
}
}
.snow .weather-icon {
animation: float-icon 4s ease-in-out infinite;
}
.snow-flakes {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
pointer-events: none;
overflow: hidden;
}
.snow-flake {
position: absolute;
color: white;
font-size: 16px;
animation: fall-snow linear infinite;
opacity: 0.8;
}
@keyframes fall-snow {
to {
transform: translateY(400px) rotate(360deg);
}
}
@keyframes float-icon {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
</style>
</head>
<body>
<h1>Animated Weather Cards</h1>
<div class="weather-container">
<div class="weather-card wind" id="wind-card">
<div class="wind-clouds">
<div class="wind-cloud"></div>
<div class="wind-cloud"></div>
<div class="wind-cloud"></div>
</div>
<div class="weather-icon">��</div>
<div class="temperature">22°</div>
<div class="condition">Windy</div>
</div>
<div class="weather-card rain" id="rain-card">
<div class="rain-drops" id="rain-drops"></div>
<div class="weather-icon">��️</div>
<div class="temperature">18°</div>
<div class="condition">Rainy</div>
</div>
<div class="weather-card sun" id="sun-card">
<div class="sun-rays">
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
<div class="sun-ray"></div>
</div>
<div class="weather-icon">☀️</div>
<div class="temperature">28°</div>
<div class="condition">Sunny</div>
</div>
<div class="weather-card snow" id="snow-card">
<div class="snow-flakes" id="snow-flakes"></div>
<div class="weather-icon">❄️</div>
<div class="temperature">-2°</div>
<div class="condition">Snowy</div>
</div>
</div>
<div class="controls">
<button onclick="showWeather('wind')" class="active">Wind</button>
<button onclick="showWeather('rain')">Rain</button>
<button onclick="showWeather('sun')">Sun</button>
<button onclick="showWeather('snow')">Snow</button>
</div>
<script>
function showWeather(weather) {
document.querySelectorAll('.weather-card').forEach(card => {
card.style.display = 'none';
});
document.getElementById(weather + '-card').style.display = 'flex';
document.querySelectorAll('button').forEach(btn => {
btn.classList.remove('active');
});
event.target.classList.add('active');
clearAnimations(weather);
startAnimations(weather);
}
function clearAnimations(activeWeather) {
const rainDrops = document.getElementById('rain-drops');
rainDrops.innerHTML = '';
const snowFlakes = document.getElementById('snow-flakes');
snowFlakes.innerHTML = '';
}
function startAnimations(weather) {
if (weather === 'rain') {
createRain();
} else if (weather === 'snow') {
createSnow();
}
}
function createRain() {
const rainDrops = document.getElementById('rain-drops');
const containerWidth = 250;
const containerHeight = 350;
for (let i = 0; i < 50; i++) {
const drop = document.createElement('div');
drop.className = 'rain-drop';
const left = Math.random() * containerWidth;
const delay = Math.random() * 5;
const duration = 1 + Math.random() * 2;
drop.style.left = left + 'px';
drop.style.animationDelay = delay + 's';
drop.style.animationDuration = duration + 's';
rainDrops.appendChild(drop);
}
}
function createSnow() {
const snowFlakes = document.getElementById('snow-flakes');
const containerWidth = 250;
const containerHeight = 350;
for (let i = 0; i < 40; i++) {
const flake = document.createElement('div');
flake.className = 'snow-flake';
flake.textContent = '❄️';
const left = Math.random() * containerWidth;
const size = 10 + Math.random() * 20;
const delay = Math.random() * 5;
const duration = 3 + Math.random() * 5;
const spin = Math.random() * 360;
flake.style.left = left + 'px';
flake.style.fontSize = size + 'px';
flake.style.animationDelay = delay + 's';
flake.style.animationDuration = duration + 's';
flake.style.transform = 'rotate(' + spin + 'deg)';
snowFlakes.appendChild(flake);
}
}
showWeather('wind');
</script>
</body>
</html>
```