View raw output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Analog Clock</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-items: center;
background: radial-gradient(circle at 50% 25%, #24364e, #0d121b 70%);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.clock {
--size: min(82vw, 82vh, 430px);
position: relative;
width: var(--size);
aspect-ratio: 1;
border-radius: 50%;
border: clamp(5px, 1.8vw, 10px) solid #111827;
background:
radial-gradient(circle at 35% 28%, #ffffff 0%, #eef2f7 48%, #cfd8e3 100%);
box-shadow:
0 24px 60px rgba(0, 0, 0, 0.5),
inset 0 0 18px rgba(15, 23, 42, 0.16);
overflow: hidden;
}
.clock::before {
content: "";
position: absolute;
inset: 4%;
border-radius: 50%;
border: 1px solid rgba(15, 23, 42, 0.18);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
z-index: 0;
}
.numbers {
position: absolute;
inset: 0;
z-index: 1;
}
.number {
position: absolute;
transform: translate(-50%, -50%);
color: #111827;
font-size: calc(var(--size) * 0.068);
font-weight: 700;
line-height: 1;
user-select: none;
}
.hand {
position: absolute;
inset: 0;
transform-origin: 50% 50%;
pointer-events: none;
}
.hand::before {
content: "";
position: absolute;
left: 50%;
bottom: 50%;
transform: translateX(-50%);
border-radius: 999px;
}
.hour {
z-index: 2;
}
.hour::before {
width: calc(var(--size) * 0.028);
height: 25%;
background: #111827;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.minute {
z-index: 3;
}
.minute::before {
width: calc(var(--size) * 0.018);
height: 35%;
background: #1f2937;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.second {
z-index: 4;
}
.second::before {
width: calc(var(--size) * 0.009);
height: 41%;
background: #dc2626;
box-shadow: 0 0 5px rgba(220, 38, 38, 0.35);
}
.second::after {
content: "";
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%);
width: calc(var(--size) * 0.014);
height: 11%;
border-radius: 999px;
background: #dc2626;
}
.pin {
position: absolute;
left: 50%;
top: 50%;
z-index: 5;
width: calc(var(--size) * 0.045);
aspect-ratio: 1;
transform: translate(-50%, -50%);
border-radius: 50%;
background: #111827;
border: 3px solid #f8fafc;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
</style>
</head>
<body>
<div class="clock" role="img" aria-label="Analog clock">
<div class="numbers" aria-hidden="true"></div>
<div class="hand hour" aria-hidden="true"></div>
<div class="hand minute" aria-hidden="true"></div>
<div class="hand second" aria-hidden="true"></div>
<div class="pin" aria-hidden="true"></div>
</div>
<script>
(() => {
const numbers = document.querySelector(".numbers");
const hourHand = document.querySelector(".hour");
const minuteHand = document.querySelector(".minute");
const secondHand = document.querySelector(".second");
const clock = document.querySelector(".clock");
for (let n = 1; n <= 12; n++) {
const angle = (n - 3) * Math.PI / 6;
const number = document.createElement("span");
number.className = "number";
number.textContent = n;
number.style.left = `${50 + 39 * Math.cos(angle)}%`;
number.style.top = `${50 + 39 * Math.sin(angle)}%`;
numbers.appendChild(number);
}
function updateClock() {
const now = new Date();
const milliseconds = now.getMilliseconds();
const seconds = now.getSeconds() + milliseconds / 1000;
const minutes = now.getMinutes() + seconds / 60;
const hours = (now.getHours() % 12) + minutes / 60;
const secondAngle = seconds * 6;
const minuteAngle = minutes * 6;
const hourAngle = hours * 30;
secondHand.style.transform = `rotate(${secondAngle}deg)`;
minuteHand.style.transform = `rotate(${minuteAngle}deg)`;
hourHand.style.transform = `rotate(${hourAngle}deg)`;
clock.setAttribute(
"aria-label",
`Analog clock showing ${now.toLocaleTimeString()}`
);
requestAnimationFrame(updateClock);
}
updateClock();
})();
</script>
</body>
</html>