Rotating Polygons - 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>Rotating Polygons</title> <style> body, html { margin: 0; padding: 0; overflow: hidden; height: 100%; background: #333; display: flex; justify-content: center; align-items: center; } .polygon { position: absolute; width: 50px; height: 50px; background: #2196f3; clip-path: polygon(50% 0%, 100% 38%, 81% 100%, 19% 100%, 0 38%); animation: rotate 8s linear infinite; } @keyframes rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } </style> </head> <body> <script> for (let i = 0; i < 30; i++) { const polygon = document.createElement('div'); polygon.className = 'polygon'; polygon.style.left = `${Math.random() * 100}vw`; polygon.style.top = `${Math.random() * 100}vh`; polygon.style.animationDuration = `${Math.random() * 6 + 2}s`; document.body.appendChild(polygon); } </script> </body> </html>