Skip to content

About

A clock drawn with 108 CSS-rotated dials that spell out the current time

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Clock

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.

Live demo · Features · Quick start · How it works

JavaScript CSS Status: complete

The dial-based digital clock showing the current time

Highlights

  • 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 --v custom property drives every size, with breakpoints at 1476 px, 1000 px and 500 px.
  • No build step. Open digi.html directly; 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.

Features

  • 108 dials. createclock() appends a .clock cell containing a .big hand, a .dot and a .small hand.
  • 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 --v CSS 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.

How it works

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"]
Loading

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.

Progress

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

Quick start

  1. Open digi.html in a browser.

    <!-- index file: digi.html -->
  2. 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

Tech stack

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

Back to top ↑

About

A clock drawn with 108 CSS-rotated dials that spell out the current time

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages