Falling Leaves - 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 Leaves</title> <style> body { margin: 0; overflow: hidden; background: #4caf50; height: 100vh; display: flex; justify-content: center; align-items: center; color: white; font-family: 'Arial', sans-serif; } .container { position: relative; width: 100%; height: 100%; } .leaf { position: absolute; top: -50px; animation: fall linear infinite; font-size: 2rem; will-change: transform; color: #8b4513; } @keyframes fall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } } .leaf:nth-child(odd) { animation-duration: 10s; } .leaf:nth-child(even) { animation-duration: 14s; } </style> </head> <body> <div class="container"> <!-- Falling leaves will be inserted here by JavaScript --> </div> <script> const container = document.querySelector('.container'); const leaves = ['🍁', '🍂', '🍃']; function createLeaf() { const leaf = document.createElement('div'); leaf.classList.add('leaf'); leaf.textContent = leaves[Math.floor(Math.random() * leaves.length)]; leaf.style.left = `${Math.random() * 100}vw`; container.appendChild(leaf); leaf.addEventListener('animationend', () => { leaf.remove(); }); } function createLeaves() { setInterval(() => { createLeaf(); }, 500); } createLeaves(); </script> </body> </html>