Falling Snowflakes - MeggiTools
Run
Toggle Theme
Share Link
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Falling Snowflakes</title> <style> body { margin: 0; overflow: hidden; background: #001f3f; height: 100vh; display: flex; justify-content: center; align-items: center; color: white; font-family: 'Arial', sans-serif; } .container { position: relative; width: 100%; height: 100%; } .snowflake { position: absolute; top: -50px; animation: fall linear infinite; font-size: 1.5rem; will-change: transform; color: white; } @keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(100vh) rotate(360deg); opacity: 0; } } .snowflake:nth-child(odd) { animation-duration: 12s; } .snowflake:nth-child(even) { animation-duration: 16s; } </style> </head> <body> <div class="container"> <!-- Falling snowflakes will be inserted here by JavaScript --> </div> <script> const container = document.querySelector('.container'); const snowflakes = ['❄️', '❅', '❆']; function createSnowflake() { const snowflake = document.createElement('div'); snowflake.classList.add('snowflake'); snowflake.textContent = snowflakes[Math.floor(Math.random() * snowflakes.length)]; snowflake.style.left = `${Math.random() * 100}vw`; container.appendChild(snowflake); snowflake.addEventListener('animationend', () => { snowflake.remove(); }); } function createSnowflakes() { setInterval(() => { createSnowflake(); }, 300); } createSnowflakes(); </script> </body> </html>