village

5 months ago
51

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Digital Clock</title>
<style>
body {
background-color: #1a1a1a;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
font-family: 'Courier New', monospace;
}

.clock-container {
background-color: #000;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.clock {
color: #0f0;
font-size: 5em;
text-shadow: 0 0 10px #0f0;
}

.colon {
animation: blink 1s step-end infinite;
}

@keyframes blink {
50% {
opacity: 0;
}
}

@media (max-width: 600px) {
.clock {
font-size: 3em;
}
}
</style>
</head>
<body>
<div class="clock-container">
<div class="clock">
<span id="hours">00</span>
<span class="colon">:</span>
<span id="minutes">00</span>
<span class="colon">:</span>
<span id="seconds">00</span>
</div>
</div>

<script>
function updateClock() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');

document.getElementById('hours').textContent = hours;
document.getElementById('minutes').textContent = minutes;
document.getElementById('seconds').textContent = seconds;
}

// Update the clock immediately and then every second
updateClock();
setInterval(updateClock, 1000);
</script>
</body>
</html>

Loading 1 comment...