Animated Counter - 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>Animated Counter</title> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #f5f7fa, #c3cfe2); font-family: 'Arial', sans-serif; margin: 0; } .counter-container { text-align: center; background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1); position: relative; } .counter-container::before { content: "🔥"; font-size: 50px; position: absolute; top: -35px; left: 50%; transform: translateX(-50%); animation: emojiBounce 2s infinite; } @keyframes emojiBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } } .counter { font-size: 100px; color: #ff4b2b; margin: 0; animation: fadeIn 2s ease-in-out; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } .label { font-size: 20px; color: #333; margin-top: 10px; letter-spacing: 1.5px; animation: slideIn 1s ease-out; } @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } .increment-btn { background: #ff4b2b; color: #fff; border: none; padding: 10px 20px; font-size: 20px; border-radius: 5px; cursor: pointer; margin-top: 20px; transition: background 0.3s; } .increment-btn:hover { background: #ff7f50; } .icon { font-size: 30px; vertical-align: middle; margin-right: 10px; animation: rotateIcon 2s infinite linear; } @keyframes rotateIcon { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } </style> </head> <body> <div class="counter-container"> <div class="icon">⭐</div> <div class="counter" id="counter">0</div> <div class="label">Visitors</div> <button class="increment-btn" onclick="incrementCounter()">Increment</button> </div> <script> let count = 0; const counterElement = document.getElementById('counter'); function incrementCounter() { count++; counterElement.textContent = count; counterElement.classList.add('scale-up'); setTimeout(() => counterElement.classList.remove('scale-up'), 500); } counterElement.addEventListener('animationend', () => { counterElement.classList.remove('scale-up'); }); </script> </body> </html>