All effectsHover & follow

Hover Card Fan

悬停卡片扇形展开

A stack spreads sideways and rotates into a fan, raising the center card.

Move the pointer, tap, or use the keyboard

Where to use it

Preview a series of related photographs, templates, or album pages. Use a small stack when the contents belong to one collection. Preserve a clear entry into the collection after the preview collapses.

Practical example

In a presentation template library, hovering over the Proposal Pack spreads its three cover previews into a fan. The front card lifts so a buyer can distinguish the main deck from its add-ons.

AI prompt

Add Hover Card Fan to [target]. Give each card a signed order index. Convert it to a horizontal offset and rotation around the common base, and animate from small offsets into wider offsets with spring-like easing. Keep the controls keyboard accessible and provide a reduced-motion state.

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>Hover Card Fan</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;
    }

    .pointer-stage {
      --x: 50%; --y: 50%; --dx: 0; --dy: 0;
      display: grid; place-items: center; position: relative;
      width: min(100%, 280px); height: clamp(106px, 68vh, 174px);
      overflow: hidden; isolation: isolate;
      border: 1px solid #b8a8ff70; border-radius: 13px;
      background: #23213e; color: #fcf9ff; cursor: pointer;
      touch-action: manipulation;
    }
    .pointer-stage:focus-visible { outline-offset: 3px; }
    .pointer-stage .tag {
      position: absolute; z-index: 4; bottom: 7px; left: 8px; color: #fff;
      background: #17152fe8; border-radius: 5px; padding: 3px 7px;
      font-size: 10px; line-height: 1.4;
    }

    .fan { position: absolute; inset: 0; display: grid; place-items: center; }
    .fan i { position:absolute; width:62px; height:76px; transform-origin:50% 85%; border:1px solid #e0e5ff9c; border-radius:9px; box-shadow:0 8px 12px #1a102b85;
      background: radial-gradient(circle at 56% 28%,#ffeabc 0 9%,transparent 10%), linear-gradient(159deg, transparent 60%,hsl(var(--hue) 54% 58%) 61%), linear-gradient(45deg,hsl(var(--hue) 54% 26%),hsl(var(--hue) 53% 60%));
      transform:translate(calc(var(--i) * 17px),calc(var(--i) * 3px)) rotate(calc(var(--i) * 6deg)); transition:transform 440ms cubic-bezier(.23,1.2,.5,1); }
    .pointer-stage:is(:hover, :focus-visible, [aria-pressed="true"]) .fan i { transform:translate(calc(var(--i) * 47px),4px) rotate(calc(var(--i) * 18deg)); }
    .pointer-stage:is(:hover, :focus-visible, [aria-pressed="true"]) .fan i:nth-child(2) { transform:translateY(-15px); z-index:1; }

    @media (prefers-reduced-motion: reduce) {
      .lab, .lab *, .lab::before, .lab::after, .lab *::before, .lab *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
      }
    }
  </style>
</head>
<body>
  <main class="demo">
    <button type="button" aria-label="Open the card fan" aria-pressed="false" class="lab pointer-stage">
    <span class="fan" aria-hidden="true"><i style="--i:-1;--hue:195"></i><i style="--i:0;--hue:239"></i><i style="--i:1;--hue:318"></i></span><span class="tag" aria-hidden="true">Print studies</span></button>
  </main>
  <script>
    const stage = document.querySelector('.pointer-stage');
    const reduced = matchMedia('(prefers-reduced-motion: reduce)');
    const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
    function setPosition(x, y) {
      stage.style.setProperty('--x', (x * 100) + '%');
      stage.style.setProperty('--y', (y * 100) + '%');
      stage.style.setProperty('--dx', 2 * x - 1);
      stage.style.setProperty('--dy', 2 * y - 1);
    }
    function position(event) {
      const bounds = stage.getBoundingClientRect();
      return [clamp((event.clientX - bounds.left) / bounds.width, 0, 1), clamp((event.clientY - bounds.top) / bounds.height, 0, 1)];
    }
    stage.addEventListener('pointermove', (event) => {
      if (event.pointerType !== 'touch' && !reduced.matches) setPosition(...position(event));
    });
    stage.addEventListener('pointerleave', () => {
      if (stage.getAttribute('aria-pressed') !== 'true') setPosition(.5, .5);
    });
    stage.addEventListener('click', (event) => {
      const active = stage.getAttribute('aria-pressed') !== 'true';
      stage.setAttribute('aria-pressed', String(active));
      setPosition(...(active && event.detail ? position(event) : active ? [.68, .38] : [.5, .5]));
    });
  </script>
</body>
</html>

Original example by UI Skills

Further examples