Floating Diamonds - 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>Floating Diamonds</title> <style> body, html { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #000; } .diamond { position: absolute; width: 20px; height: 20px; background: #ff0000; transform: rotate(45deg); animation: float 4s infinite; } @keyframes float { 0% { transform: translateY(0) rotate(45deg); } 50% { transform: translateY(-20px) rotate(45deg); } 100% { transform: translateY(0) rotate(45deg); } } </style> </head> <body> <script> for (let i = 0; i < 50; i++) { const diamond = document.createElement('div'); diamond.className = 'diamond'; diamond.style.left = `${Math.random() * 100}%`; diamond.style.top = `${Math.random() * 100}%`; diamond.style.animationDuration = `${Math.random() * 4 + 2}s`; document.body.appendChild(diamond); } </script> </body> </html>