全部效果自动播放与循环

脉冲缩放

Pulse

标记有规律地短暂放大,再缩回原来的尺寸。

播放或暂停演示

适用场景

突出地图中的实时位置或一个活跃状态标记。 让脉冲对应一个真实的活跃状态,图形缩放时保持标记的可点击范围稳定。

应用示例

机场接驳地图上,正在共享位置的班车标记每隔几秒轻轻放大,再缩回原来的尺寸。旅客始终可以点同一个位置查看到站时间。

AI 提示词

给【目标标记】加脉冲缩放。用 transform 关键帧放大至 1.16 倍再还原,每次之间停顿一小段。让点击区域尺寸保持稳定,循环播放提供暂停,减少动态模式显示原尺寸。

示例代码

保存为 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;
    }

    .pulse-target {
      width: 61px; aspect-ratio: 1; border: 1px solid #ffa9be;
      background: #e26391; border-radius: 22px; box-shadow: 0 0 0 8px #ec709731;
      animation: pulse 1.5s ease-in-out infinite;
    }
    @keyframes pulse { 0%, 30%, 100% { transform: scale(1); } 57% { transform: scale(1.16); } }

    .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; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="motion-example">
      <div class="motion-specimen" aria-hidden="true"><span class="pulse-target" data-motion></span></div>
      <button class="demo-button" type="button" data-loop-toggle data-testid="effect-demo-loop-toggle">播放演示</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 ? "暂停演示" : "播放演示";
    });
  </script>
</body>
</html>

UI Skills 原创示例