全部效果自动播放与循环

扫光文字

Sheen Text

一道窄高光扫过文字笔画,在字形内部移动。

播放演示,观察高光扫过文字

适用场景

给标题、产品名或简短口号加一道点缀高光。 确保高光扫过前后文字都清楚,把反复运动集中在短文案上。

应用示例

钟表品牌给系列名称加了一道窄高光,访客触发后,高光仅从字形内部经过。

也叫

  • 文字扫光
  • 文字流光

AI 提示词

给【标题】加上扫光文字。保留现有字体,让一道窄高光在循环播放或悬停时扫过字形。减少动态效果模式下暂停扫光。

示例代码

保存为 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 { background: radial-gradient(ellipse at 50% 45%, #3c3026, #1a1715 77%); }
    .motion-example { max-width: 100%; }
    .sheen-type {
      margin: 0;
      color: #d2a586;
      font: 400 clamp(29px, 14vw, 72px)/1.2 Georgia, serif;
      letter-spacing: -.065em;
    }
    @supports (background-clip: text) {
      .sheen-type {
        color: transparent;
        background: linear-gradient(102deg, #af8c75 0 38%, #ffd2a6 47%, #fff5d1 50%, #d9ad8d 54%, #b28b72 64% 100%) 49% 0 / 235% 100%;
        background-clip: text;
        animation: sweep 2.6s cubic-bezier(.4, 0, .36, 1) infinite;
        animation-delay: -1s;
      }
    }
    @keyframes sweep {
      0%, 8% { background-position: 100% 0; }
      73%, 100% { background-position: 0 0; }
    }
    @media (forced-colors: active) { .sheen-type { color: CanvasText; background: none; } }

    .motion-example { display: grid; place-items: center; gap: 12px; }
    .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 button { display: none; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="motion-example">
      <p class="sheen-type" data-motion>余辉</p>
      <button class="demo-button" type="button" data-testid="effect-demo-loop-toggle">播放演示</button>
    </div>
  </main>
  <script>
    const example = document.querySelector('.motion-example');
    const toggle = example.querySelector('button');
    toggle.addEventListener('click', () => {
      const playing = example.toggleAttribute('data-playing');
      toggle.textContent = playing ? "暂停演示" : "播放演示";
    });
  </script>
</body>
</html>

UI Skills 原创示例