大网数据广告活动
Web 标准与前端开发

keyPoints

· 52CE 我爱测

The **`keyPoints`** attribute indicates, in the range [0,1], how far the object is along the path for each associated value in keyTimes.

The keyPoints attribute indicates, in the range [0,1], how far the object is along the path for each associated value in keyTimes.

You can use this attribute with the following SVG elements:

  • animate
  • animateMotion
  • animateTransform
  • set

Example

html,
body,
svg {
  height: 100%;
}
<svg
  viewBox="0 0 120 120"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <path
    d="M10,110 A120,120 -45 0,1 110 10 A120,120 -45 0,1 10,110"
    stroke="lightgrey"
    stroke-width="2"
    fill="none"
    id="motionPath" />
  <circle cx="10" cy="110" r="3" fill="lightgrey" />
  <circle cx="110" cy="10" r="3" fill="lightgrey" />

  <circle r="5" fill="red">
    <animateMotion
      dur="3s"
      repeatCount="indefinite"
      keyPoints="0;0.5;1"
      keyTimes="0;0.15;1"
      calcMode="linear">
      <mpath href="#motionPath" />
    </animateMotion>
  </circle>
</svg>

Example

Usage notes

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td>number [; number ]* ;?</td> </tr> <tr> <th scope="row">Default value</th> <td><em>None</em></td> </tr> <tr> <th scope="row">Animatable</th> <td>No</td> </tr> </tbody> </table>

  • <number> [; <number>] ;?
    • : This value defines a semicolon-separated list of floating point values between 0 and 1 and indicates how far along the motion path the object shall move at the moment in time specified by corresponding keyTimes value. The distance is calculated along the path specified by the path attribute. Each progress value in the list corresponds to a value in the keyTimes attribute list.

      If a list of key points is specified, there must be exactly as many values in the keyPoints list as in the keyTimes list.

      If there's a semicolon at the end of the value, optionally followed by white space, both the semicolon and the trailing white space are ignored.

      If there are any errors in the value specification (i.e., bad values, too many or too few values), then that's an error.

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。