Dark Mode Timer - 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>Dark Mode Timer</title> <style> body { font-family: 'Roboto', sans-serif; background: #121212; color: #e0e0e0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; } .timer-container { background: #1e1e1e; border-radius: 15px; box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); padding: 30px; text-align: center; max-width: 400px; width: 100%; } .timer { font-size: 3em; margin: 20px 0; color: #bb86fc; } .controls { display: flex; justify-content: space-around; } button { background: #6200ea; border: none; border-radius: 5px; color: #fff; padding: 10px 20px; font-size: 1em; cursor: pointer; transition: background 0.3s; } button:hover { background: #3700b3; } button:disabled { background: #ccc; cursor: not-allowed; } </style> </head> <body> <div class="timer-container"> <h1>Dark Mode Timer</h1> <div class="timer" id="timer">00:00:00</div> <div class="controls"> <button id="start">Start</button> <button id="stop" disabled>Stop</button> <button id="reset" disabled>Reset</button> </div> </div> <script> let timerInterval; let elapsedTime = 0; const timerElement = document.getElementById('timer'); const startButton = document.getElementById('start'); const stopButton = document.getElementById('stop'); const resetButton = document.getElementById('reset'); function updateTimer() { const hours = String(Math.floor(elapsedTime / 3600)).padStart(2, '0'); const minutes = String(Math.floor((elapsedTime % 3600) / 60)).padStart(2, '0'); const seconds = String(elapsedTime % 60).padStart(2, '0'); timerElement.textContent = `${hours}:${minutes}:${seconds}`; } function startTimer() { startButton.disabled = true; stopButton.disabled = false; resetButton.disabled = true; timerInterval = setInterval(() => { elapsedTime++; updateTimer(); }, 1000); } function stopTimer() { clearInterval(timerInterval); startButton.disabled = false; stopButton.disabled = true; resetButton.disabled = false; } function resetTimer() { elapsedTime = 0; updateTimer(); resetButton.disabled = true; } startButton.addEventListener('click', startTimer); stopButton.addEventListener('click', stopTimer); resetButton.addEventListener('click', resetTimer); </script> </body> </html>