Untitled

 avatar
unknown
plain_text
9 days ago
1.3 kB
0
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1 Minute Timer</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f4f4f9;
        }
        .timer {
            font-size: 48px;
            background: #333;
            color: white;
            padding: 20px;
            border-radius: 10px;
        }
    </style>
</head>
<body>
    <div class="timer" id="timer">01:00</div>

    <script>
        let time = 60; // 1 minute in seconds
        const timerElement = document.getElementById('timer');

        function updateTimer() {
            const minutes = Math.floor(time / 60);
            const seconds = time % 60;
            timerElement.textContent = `${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
            if (time === 0) {
                clearInterval(interval);
                alert("Time's up!");
            } else {
                time--;
            }
        }

        const interval = setInterval(updateTimer, 1000);
    </script>
</body>
</html>
Leave a Comment