All effectsPlay & loop

Flip Clock

翻页时钟

The top half of a split time card flips down to show the next digit.

Play or pause the demo

Where to use it

Give a short countdown or decorative clock a mechanical rhythm. Use a small number of fixed-width digits for a time that changes at a predictable interval.

Practical example

An online film screening shows the minutes and seconds remaining until it starts. Each second turns down the top half of the changing tile and reveals the next number, while the “Starts in” label stays fixed.

AI prompt

Build a Flip Clock for [target time display]. Segment each digit into two clipped halves and rotate the outgoing top flap around its lower edge. Advance an actual time value after the fold, preserve a readable text alternative, and display a static digit with reduced motion.

Example code

Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.

View HTML
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Flip Clock</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .flap-time { display: flex; align-items: center; gap: 5px; color: #fff4db; font: 750 30px/1 ui-monospace, monospace; }
    .flap-time > b span { padding-left: 4px; color: #c6889b; }
    .flap-digit {
      position: relative; display: grid; place-items: center; width: 73px; height: 60px;
      overflow: hidden; perspective: 180px; border-radius: 8px; background: #45334e;
    }
    .flap-digit::after { content: ''; position: absolute; inset: 50% 0 auto; height: 1px; background: #171326; }
    .flap-next, .flap-panel { position: absolute; inset: 0; display: grid; place-items: center; background: #45334e; }
    .flap-next { animation: clock-next 4.2s steps(1) infinite; }
    .flap-panel { clip-path: inset(0 0 50%); background: #594364; animation: clock-flap 4.2s ease-in-out infinite; }
    @keyframes clock-next { 0%, 25%, 92%, 100% { visibility: hidden; } 26%, 91% { visibility: visible; } }
    @keyframes clock-flap { 0%, 25% { transform: rotateX(0); } 42%, 86% { transform: rotateX(-95deg); } 95%, 100% { transform: rotateX(0); } }

    .motion-example { display: grid; justify-items: center; width: 100%; gap: 10px; }
    .motion-specimen {
      display: grid;
      place-items: center;
      width: min(100%, 295px);
      height: 108px;
      position: relative;
      isolation: isolate;
    }
    .motion-example [data-motion] { animation-play-state: paused; }
    .motion-example[data-playing] [data-motion] { animation-play-state: running; }
    @media (prefers-reduced-motion: reduce) {
      .motion-example [data-motion] { animation: none; }
      .motion-example [data-loop-toggle] { display: none; }
    }

    @media (prefers-reduced-motion: reduce) { .flap-next, .flap-panel { display: none; } }
  </style>
</head>
<body>
  <main class="demo">
    <div class="motion-example">
      <div class="motion-specimen" aria-hidden="true"><div class="flap-time"><b>12<span>:</span></b><div class="flap-digit"><b>08</b><b class="flap-next" data-motion>09</b><b class="flap-panel" data-motion>08</b></div></div></div>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">Play demo</button>
    </div>
  </main>
  <script>
    const example = document.querySelector('.motion-example');
    const toggle = example.querySelector('[data-loop-toggle]');

    toggle.addEventListener('click', () => {
      const playing = example.toggleAttribute('data-playing');
      toggle.textContent = playing ? "Pause demo" : "Play demo";
    });
  </script>
</body>
</html>

Original example by UI Skills