Introduction
This is a single HTML file that shows the date as three rings around an analog clock. The outer ring holds the numbers 01 to 31, the middle ring holds the months and the inner ring holds the weekdays. When the page loads, each ring fades from a label like DAY or MONTH into its full list, then spins until today is at the top and lights up in colour: pink for the date, blue for the month and green for the weekday. Last, a small person icon in the middle fades into a live clock with hour, minute and second hands.
There is no SVG, no canvas and no library. Every letter is its own span, rotated around the centre with a CSS transform. One formula works out how far to turn each ring, and the hands are three rotated divs driven by a tick loop that stays in step with the real clock.
How to draw a three-quarter ring with one border — how to bend text around a circle with tall, thin spans — how to work out the rotation that brings any item to the top — how to write a step-by-step intro with async and await that can be safely restarted — how to make clock hands that never spin backwards and do not drift — and how to scale a layout built in pixels down to fit any screen.
Step 1 — Three Rings and a Clock on One Stage
Everything sits inside a 450 by 450 pixel stage. The three rings are 450, 350 and 250 pixels wide and are all centred with the same top: 50%, left: 50% and translate(-50%, -50%). Each ring is 100 pixels smaller than the one outside it, which leaves exactly one 45 pixel band of text per ring with a 5 pixel gap between them. The clock face is a 150 pixel circle on top of them all.
<main class="stage" id="stage">
<div class="ring ring-date" data-ring="date">
<div class="outer-ring"></div>
<div class="inner-ring">
<h1 class="ring-label fadeable">DAY</h1>
<h2 class="ring-content fadeable"></h2>
</div>
</div>
<div class="ring ring-month" data-ring="month"> ...MONTH... </div>
<div class="ring ring-weekday" data-ring="weekday"> ...DAY NAME... </div>
<div class="clock-center" id="clock" role="button" tabindex="0">
<div class="clock-face fadeable"> <!-- HELLO + person icon --> </div>
<div class="clock-hands fadeable"> <!-- hour, minute, second --> </div>
</div>
</main>Each ring has a short label (DAY, MONTH, DAY NAME) and an empty content heading. The content is filled in by JavaScript from an array, so the months and weekdays are written once in the script instead of being typed out as long strings in the HTML.
.stage {
position: relative;
width: 450px;
height: 450px;
transform: scale(var(--scale)); /* set by JS on small screens */
}
.ring {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.ring-weekday { width: 250px; height: 250px; }
.ring-month { width: 350px; height: 350px; }
.ring-date { width: 450px; height: 450px; }Step 2 — One Border, Three Sides
Each ring is drawn twice. The outer-ring is a faint white track at 10% opacity that goes all the way round. On top of it, the inner-ring is a dark band made from a thick 45 pixel border with border-radius: 50%. Its bottom border is transparent, so the band covers the top, left and right and leaves the bottom quarter open.
.outer-ring {
width: 100%;
height: 100%;
border: 10px solid transparent;
border-radius: 50%;
opacity: .1;
}
.outer-ring::before {
content: "";
position: absolute;
inset: 5px;
border: 35px solid #fff;
border-radius: 50%;
}
.inner-ring {
position: relative;
top: -100%; /* sit exactly on top of the track */
width: 100%;
height: 100%;
border: 45px solid #202020;
border-bottom-color: transparent; /* the open quarter */
border-radius: 50%;
box-shadow: 0 -2px 2px #000;
transition: transform 1s cubic-bezier(.22, 1, .36, 1);
}With a round border, each side covers a quarter of the circle. Three solid sides make a 270 degree arc, from -135 degrees on the left, over the top, to 135 degrees on the right. That 270 is the most important number in the file: the text is spread over exactly that arc, so when the inner-ring rotates, the dark band and the text on it move together and the gap always lines up with the unused part of the list.
Because only the dark band rotates and the faint track stays still, you can see the ring turn. As it spins, the gap sweeps round the track, which makes the movement easy to follow without any extra effect.
Step 3 — Tall, Thin Spans That Rotate from the Centre
CSS has no simple way to set text on a curve, so the text is split into one span per letter. Each span is a tall, narrow box: 12 pixels wide and as tall as the ring, centred horizontally. The letter sits at the top of the box. Because transform-origin is the centre of the box, which is also the centre of the ring, rotating the span swings the letter round the circle like a clock hand.
.ring-content span {
position: absolute;
left: calc(50% - 6px);
width: 12px;
text-align: center;
transform-origin: center center;
transition: color .4s;
}
/* each span is as tall as its ring, so its centre is the ring's centre */
.ring-date .ring-content span { top: calc(-25% + 55px); height: 432px; }
.ring-month .ring-content span { top: calc(-25% + 30px); height: 332px; }
.ring-weekday .ring-content span { top: calc(-25% + 5px); height: 232px; }The span heights are a little smaller than the rings (432 inside 450), which brings the letters in from the edge so they sit in the middle of the dark band. The labels use the same idea with a slightly larger box, so DAY or MONTH sits just outside the content text.
Working out each angle
A small letter() function does the splitting. It takes an element, the text and the arc to spread it over. The arc is split into (letters + 1) equal steps, and letter i goes at step i + 1. Leaving one extra step means there is half a gap at each end, so the text is always centred on the arc.
function letter(el, text, arc) {
const chars = [...text];
const step = arc / (chars.length + 1);
el.textContent = '';
return chars.map((ch, i) => {
const span = document.createElement('span');
span.textContent = ch;
span.style.transform = `rotate(${-arc / 2 + step * (i + 1)}deg)`;
el.appendChild(span);
return span;
});
}
letter(label, 'MONTH', 90); // short label, 90° arc
letter(content, 'JAN FEB MAR ... DEC', 270); // full list, 270° arc
letter(document.querySelector('.initial-text'), 'HELLO', 120);The spaces between tokens are letters too. "JAN FEB" is seven spans, not six, and the space span is what makes the gap between months. The function returns its spans, so the script can group them by token: with 3-letter months, token i is spans i × 4 to i × 4 + 3. Those groups are what get the highlight colour later.
const RINGS = {
date: { tokens: Array.from({ length: 31 }, (_, i) => String(i + 1).padStart(2, '0')) },
month: { tokens: ['JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC'] },
weekday: { tokens: ['MON','TUE','WED','THU','FRI','SAT','SUN'] }
};
const spans = letter(content, ring.tokens.join(' '), 270);
const len = ring.tokens[0].length; // 2 or 3 letters
ring.groups = ring.tokens.map((_, i) =>
spans.slice(i * (len + 1), i * (len + 1) + len)); // skip the spaceAn older version of this demo generated its CSS from fixed numbers like 28, 48 and 93, one for each ring's letter count. Change a single word and every letter moved to the wrong place. Working out the count from the text itself, and setting the rotation as an inline style, means you can change the lists or the labels freely.
Step 4 — One Formula for Every Ring
Each ring splits its 270 degrees into equal segments, one per token: 270 / 31 for dates, 270 / 12 for months and 270 / 7 for weekdays. The first token starts at -135 degrees, so the middle of token v is at -135 + seg × (v - 1) + seg / 2. To bring that point to the top, the ring has to turn by the same amount the other way.
const ARC = 270;
function selectToken(ring, value) { // value is 1-based
const seg = ARC / ring.tokens.length;
const angle = 135 - seg / 2 - seg * (value - 1);
ring.inner.style.transform = `rotate(${angle}deg)`;
ring.groups.forEach((g, i) =>
g.forEach(s => s.classList.toggle('is-active', i === value - 1)));
}Take the 1st of the month: the angle is 135 - 4.35 = 130.6 degrees, which swings the far-left 01 all the way round to the top. For the 31st it is about -130.6 degrees, which brings the far-right 31 back to the top. Because the inner-ring has a one second transition with a soft ease-out, setting the transform is all it takes to get a smooth spin.
The highlight is a class instead of a hard-coded colour. Each ring sets its own --accent variable, and .is-active uses it. toggle(name, force) adds the class to today's spans and removes it from every other span, so an old highlight never stays behind when the date changes.
.ring-weekday { --accent: #4cd964; }
.ring-month { --accent: #007aff; }
.ring-date { --accent: #ff2d55; }
.ring-content .is-active { color: var(--accent); }One small catch is the weekday. getDay() returns 0 for Sunday, but the ring starts with MON, so Monday must be 1 and Sunday must be 7. d.getDay() || 7 turns the 0 into a 7 and leaves every other day as it is.
One formula, three rings. The only thing that changes is how many slices the 270 degrees is cut into.
Step 5 — Fade, Wait, Spin, Repeat
The intro plays from the outside in. For each ring, the label fades out while the full list fades in, and then the ring spins to today. After all three, the HELLO face fades out and the clock hands fade in. All the fades are plain CSS opacity transitions, switched on by adding one is-open class.
.fadeable { transition: opacity .5s ease; }
.ring-content,
.clock-hands { opacity: 0; }
.ring.is-open .ring-label { opacity: 0; }
.ring.is-open .ring-content { opacity: 1; }
.clock-center.is-open .clock-face { opacity: 0; }
.clock-center.is-open .clock-hands { opacity: 1; }The order is written as an async function that reads top to bottom. A wait() helper wraps setTimeout in a promise, so each step can await the one before it. The ring only spins after its fade has finished, so you see the full list arrive before it moves.
const wait = ms => new Promise(r => setTimeout(r, ms));
let runId = 0;
async function intro() {
const id = ++runId;
reset(); // close rings, rotate to 0, clear highlights
const parts = dateParts();
for (const key of ['date', 'month', 'weekday']) {
await wait(500);
if (id !== runId) return;
RINGS[key].root.classList.add('is-open'); // label out, list in
await wait(500); // let the fade finish
if (id !== runId) return;
selectToken(RINGS[key], parts[key]); // spin to today
}
clock.classList.add('is-open'); // HELLO out, hands in
}
clock.addEventListener('click', intro);Safe to click again
Clicking the centre replays the intro, and someone will click it while it is still running. Each run takes a number from runId, and after every await it checks that it is still the newest one. If a newer run has started, the old one simply stops, so two runs never fight over the same rings.
The centre is clickable, so a button seems right. But it holds headings and divs, and a button can only contain inline content. Instead it is a div with role="button" and tabindex="0", plus a keydown handler for Enter and Space, so it still works from the keyboard and is announced as a button.
Step 6 — Three Rotated Wrappers and a Drift-Free Tick
Each hand uses the same trick as the letters. A 25 by 150 pixel wrapper fills the clock face from top to bottom and rotates around its centre. The hand inside it is a rounded bar that starts near the top and ends just past the middle, so it points from the centre outwards.
.pointer-wrapper {
position: absolute;
top: 0;
left: calc(50% - 12.5px);
width: 25px;
height: 150px;
transform-origin: center center;
}
.pointer-hour { top: 30px; width: 10px; height: 50px; background: #fff; }
.pointer-minute { top: 10px; width: 10px; height: 70px; background: #ccc; }
.pointer-second { top: 6px; width: 2px; height: 70px; background: #aaa; }
#sec-wrapper { transition: transform .25s cubic-bezier(.4, 2.2, .6, 1); }
#min-wrapper,
#hr-wrapper { transition: transform .5s ease; }The second hand's cubic-bezier has a y value of 2.2, which overshoots and settles back. That gives each tick a small spring, like a real quartz clock. There is a problem though. When the seconds go from 59 back to 0, the angle drops from 354 to 0 degrees, and the transition takes the short way: it spins backwards almost a full circle.
Keep adding, never go back
The fix is to never set a smaller angle. The script remembers each hand's last angle. For a new target between 0 and 360, it finds the matching angle in the current turn, and if that would be behind the last one it adds a full 360. So after 354 comes 360, not 0, and the hand keeps moving forwards.
const angles = { sec: 0, min: 0, hr: 0 };
function advance(name, target) {
const prev = angles[name];
let next = prev - (((prev % 360) + 360) % 360) + target; // same turn as prev
if (next < prev) next += 360; // never go backwards
angles[name] = next;
hands[name].style.transform = `rotate(${next}deg)`;
}The minute hand moves a tenth of a degree every second and the hour hand moves half a degree every minute, so they creep forward smoothly instead of jumping. getHours() % 12 keeps the hour on a 12 hour face.
function tick() {
const now = new Date();
const s = now.getSeconds(), m = now.getMinutes(), h = now.getHours() % 12;
advance('sec', s * 6);
advance('min', m * 6 + s * 0.1);
advance('hr', h * 30 + m * 0.5);
// start the next tick at the very start of the next second
tickTimer = setTimeout(tick, 1000 - now.getMilliseconds());
}
tick(); // run once straight away, so the hands are right on the first framesetInterval(fn, 1000) slowly drifts, because each call runs a few milliseconds late and those delays add up. It can also tick at, say, 0.9 seconds past the real second, so the clock looks a second behind your computer. Waiting 1000 - getMilliseconds() each time keeps every tick lined up with the real second. Calling tick() once at start-up also means the hands show the right time straight away instead of sitting at 12:00 for the first second.
Step 7 — The Details That Make It Last
Rolling over at midnight
A clock is often left open for days. On every tick the script compares today's toDateString() with the last one. When it changes, it calls selectToken() on all three rings, so they spin to the new day by themselves, and the month and weekday follow when needed.
const parts = dateParts(now);
if (currentDay && parts.key !== currentDay && stage.dataset.ready) {
Object.keys(RINGS).forEach(k => selectToken(RINGS[k], parts[k]));
}
currentDay = parts.key;Scaling the whole stage
Every letter is placed with exact pixel offsets, so shrinking each ring separately with vw units would push the letters off their bands. Instead the 450 pixel stage is drawn at full size and scaled as one piece. On resize, the script works out how much space there is with a 16 pixel gap on each side and writes the scale to a --scale variable.
function fit() {
const size = Math.min(window.innerWidth, window.innerHeight) - 32;
document.documentElement.style.setProperty('--scale', Math.min(1, size / 450));
}
window.addEventListener('resize', fit);Motion, background tabs and screen readers
If the visitor has asked for less motion, wait() resolves straight away and the transitions are turned off, so the rings jump to today without spinning. When the tab is hidden the tick stops, and when it comes back it starts again at once so the hands catch up. Because the date is shown as rotated single letters, which a screen reader would read as nonsense, a hidden aria-live paragraph reads out the full date, such as Thursday, 26 November 2026, once the intro has finished.
const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
const wait = ms => new Promise(r => setTimeout(r, reduceMotion ? 0 : ms));
document.addEventListener('visibilitychange', () => {
clearTimeout(tickTimer);
if (!document.hidden) tick();
});
srDate.textContent = new Date().toLocaleDateString(undefined, {
weekday: 'long', day: 'numeric', month: 'long', year: 'numeric'
});Tuning Reference
| Value | Example | Effect |
|---|---|---|
| ARC | 270deg | How much of each ring holds text; must match the three solid borders |
| STEP_MS | 500ms | Pause between intro steps, and how long each fade has to finish |
| ring sizes | 450 / 350 / 250px | Diameter of the date, month and weekday rings |
| inner-ring border | 45px | Thickness of each dark text band |
| inner-ring transition | 1s cubic-bezier(.22,1,.36,1) | Speed and feel of the spin to today |
| label arc | 90deg | How spread out DAY, MONTH and DAY NAME are |
| --accent | #ff2d55 / #007aff / #4cd964 | Highlight colour for date, month and weekday |
| second hand ease | cubic-bezier(.4, 2.2, .6, 1) | The springy overshoot on each tick |
| --scale | 0–1 | Set by fit(); shrinks the whole stage on small screens |
Full Source Code
The whole project is a single self-contained HTML file with its markup, styles and script together and no build step. The only external request is the Google Fonts stylesheet for Roboto Mono, and the page falls back to the system monospace font if it does not load. It works in any current Chrome, Edge, Safari or Firefox.
// Full source available in the Aduok GitHub repository
// https://github.com/aduok/aduok-code-snippets/blob/main/blog/circular-calendar-clock.html