A clock drawn with CSS-rotated cells instead of text: 108 small dials rotate to spell the current time.
Vanilla JavaScript builds the dials and a lookup table maps each digit to two hand angles.
- Digits without text. 108 dial cells are created in JavaScript and laid out with flexbox; no digit glyphs are drawn.
- Two rotating hands per cell. A lookup table gives each digit a minute-hand and hour-hand angle, and the hands glide into place with a 5 s CSS transition.
- Single-variable scaling. One
--vcustom property drives every size, with breakpoints at 1476 px, 1000 px and 500 px. - No build step. Open
digi.htmldirectly; there are no dependencies or install commands. - Minute-boundary refresh. A one-second interval watches for the start of a new minute and reloads shortly after it.
- 108 dials.
createclock()appends a.clockcell containing a.bighand, a.dotand a.smallhand. - Four-dial digits. Each digit uses four dials; the two hands per dial are rotated from a lookup table, one for the minute hand and one for the hour hand.
- Hours and minutes. Four digits plus a separator dot.
- Gliding hands. A 5 s CSS transition animates each change between digits.
- Colour background. Keyframes cycle the background colours over 20 s.
- Responsive layout. The
--vCSS variable scales the whole clock down at 1476 px, 1000 px and 500 px breakpoints. - Current time. The page reloads shortly after each new minute to pick up the current time.
flowchart LR
A["Page load"] --> B["createclock builds 108 dials"]
B --> C["Date reads local time"]
C --> D["Lookup table o maps digits to angles"]
D --> E["CSS transitions move the hands"]
E --> F["refresh reloads at the minute boundary"]
createclock() appends a .clock cell containing a .big hand, a .dot and a .small hand. The o array stores rotation pairs per digit, and hello(), hello1(), hello2(), hello3() and dot() write those rotations onto the correct cells for the tens and units of hours and minutes. Dials that should stay hidden use a fixed 120° entry in the table. refresh() runs every second and schedules a reload just after the seconds reach zero.
| Area / Feature | Status | Notes |
|---|---|---|
| Dial rendering and layout | ✅ Done | createclock() in digi.js |
| Hour and minute display | ✅ Done | lookup table o |
| Animation and colour background | ✅ Done | digi.css |
| Live ticking | 🚧 In progress | page reloads once a minute instead of updating in place |
| Seconds display | ⏳ Planned | only hours and minutes are rendered |
-
Open
digi.htmlin a browser.<!-- index file: digi.html --> -
The clock shows the current local time; leave it open and it refreshes each minute.
No build step, no dependencies, no install.
Project structure
digitalclock/
├── digi.html # page shell, load handler, analytics tag
├── digi.js # builds the dials, maps digits to rotations
└── digi.css # cell, hand and background styling, breakpoints
| Layer | Technology |
|---|---|
| Logic | Vanilla JavaScript (DOM creation, Date, setTimeout) |
| Styling | CSS conic gradients for the hands, custom property --v for scaling, keyframes for the background |
| Analytics | Google Analytics tag in the page head |
