Colorful Dots Animation
Home
Snippets
Colorful Dots Animation
HTML
CSS
JS
<div class="spiral-container" id="spiralContainer"></div>
* { box-sizing: border-box; margin: 0; padding: 0; } body { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #000; overflow: hidden; } .spiral-container { position: relative; width: 400px; height: 400px; display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); gap: 5px; } .spiral-cell { width: 100%; height: 100%; border-radius: 50%; background: conic-gradient(from 180deg, #ff6b6b, #f39c12, #3498db, #8e44ad, #ff6b6b); animation: rotate 20s linear infinite; transform-origin: center; } @keyframes rotate { 0% { transform: scale(0.5) rotate(0deg); } 50% { transform: scale(1) rotate(180deg); } 100% { transform: scale(0.5) rotate(360deg); } }
const container = document.getElementById('spiralContainer'); const totalCells = 100; // Total number of grid cells in a spiral const colors = ["#ff6b6b", "#f39c12", "#3498db", "#8e44ad"]; function createSpiral() { for (let i = 0; i < totalCells; i++) { const cell = document.createElement('div'); cell.classList.add('spiral-cell'); const randomColor = colors[Math.floor(Math.random() * colors.length)]; cell.style.background = randomColor; cell.style.animationDelay = `${i * 0.05}s`; container.appendChild(cell); } } createSpiral();
Ad #1
Ad #2
Scroll to Top