全部效果滚动与入场

交错入场

Staggered Reveal

同组元素按顺序出现,相邻元素的入场时间错开一小段。

播放入场顺序

适用场景

让功能网格或短列表沿阅读顺序逐项出现。 适合视口内一小组内容。每项之间只留很短的间隔,读者能很快看完整组。

应用示例

绘画课的总览页有「准备」「起稿」「上墨」「检查」四张卡片。整行进入视口时,卡片按阅读顺序依次出现,学员能顺着课程步骤往下看。

也叫

  • 错峰入场
  • 错列入场

AI 提示词

给【目标列表】加上 Staggered Reveal。整组进入视口后,按照 DOM 顺序让成员短暂淡入并轻微移动,相邻起始时间间隔约 60 毫秒,并限制总延时。保持原布局与键盘顺序,减少动态效果模式下即刻显示所有成员。

示例代码

保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。

查看 HTML
<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>交错入场</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;
    }

    .demo-action {
      padding: 7px 14px;
      border: 1px solid #61577d;
      border-radius: 999px;
      color: #f7f3ff;
      background: #322b47;
      font: inherit;
      font-size: 12px;
      font-weight: 650;
      cursor: pointer;
    }
    .demo-action:hover { background: #413657; }

    .stagger-scene { display: grid; justify-items: center; gap: 10px; width: min(100%, 172px); }
    .stagger-rows { display: grid; gap: 5px; width: 100%; padding: 0; margin: 0; list-style: none; }
    .stagger-rows li {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 10px;
      color: #f2e9ff;
      background: #332747;
      border: 1px solid #57466e;
      border-radius: 6px;
      font-size: 11px;
    }
    .stagger-rows i { width: 8px; height: 8px; border-radius: 3px; background: #bdacff; }
    .stagger-rows li:nth-child(2) i { background: #f4b495; }
    .stagger-rows li:nth-child(3) i { background: #9ce2bd; }
  </style>
</head>
<body>
  <main class="demo">
    <div class="stagger-scene">
      <ul class="stagger-rows">
        <li><i aria-hidden="true"></i>色彩样本</li><li><i aria-hidden="true"></i>图标网格</li><li><i aria-hidden="true"></i>版式草图</li>
      </ul>
      <button class="demo-action stagger-play" type="button">逐项播放</button>
    </div>
  </main>
  <script>
    const play = document.querySelector(".stagger-play");
    const rows = document.querySelectorAll(".stagger-rows li");
    const reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)");
    let animations = [];

    function resetAnimations() {
      animations.forEach((animation) => animation.cancel());
      animations = [];
    }

    reduceMotion.addEventListener("change", resetAnimations);
    play.addEventListener("click", () => {
      resetAnimations();
      if (reduceMotion.matches || !Element.prototype.animate) return;
      animations = Array.from(rows, (row, index) => row.animate(
        [
          { opacity: 0.15, transform: "translateX(-12px)" },
          { opacity: 1, transform: "translateX(0)" },
        ],
        { duration: 360, delay: index * 115, fill: "backwards", easing: "ease-out" }
      ));
    });
  </script>
</body>
</html>

UI Skills 原创示例