html - 如何同步 SVG 动画?

标签 html css svg

我想让一个矩形在圆圈移动 2 秒后移动。我给每个动画一个 ID,然后将 ID 与开始事件引用一起使用。但是,似乎没有任何效果。

<svg width="800" height="600" style="background-color:black">

<circle id="circle" cx="30" cy="100" r="20" fill="gold" />

<animate
xlink:href="#circle"
attributeName="cx"
from="30"
to="750"
dur="4s"
repeatCount="indefinite"
id="circ-anim" />

<rect id="rectangle" x="50" y="400" width="50" height="20" fill="gold" />

<animate
xlink:href="#rectangle"
attributeName="x"
dur="3s"
from="50"
to="450
begin="circ-anim.begin + 2s"
id="rect-anim" />

</svg>

最佳答案

更多信息 here .您还可以添加另一个起点。我已将所有内容都放在一个片段中,就像上面 CeeJay 所说的那样。

<svg width="800" height="600" style="background-color:black">

<circle id="circle" cx="30" cy="100" r="20" fill="gold" />

<animate
xlink:href="#circle"
attributeName="cx"
from="30"
to="750"
dur="4s"
repeatCount="indefinite"
id="circanim" />

<rect id="rectangle" x="50" y="400" width="50" height="20" fill="gold" />

<animate
xlink:href="#rectangle"
attributeName="x"
dur="3s"
from="50"
to="450"
begin="circanim.begin+2s"
id="rectanim"
repeatCount="indefinite"/>

</svg>

关于html - 如何同步 SVG 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45607937/

相关文章:

html - <svg> 没有缩放到页面宽度的问题

c# - 将图像(JPG、BMP、GIF)转换为 SVG

javascript - 使用数字和字符串对列进行排序

带有选择长时间运行脚本的javascript动态内容

html - 更改 <h1> 颜色 - Designfolio WP 主题。谷歌字体?

css - 如果我添加边距,Bootstrap 列不会填满网格

html - 图像剪辑与 css 问题

html - 边框图像出现在所有菜单项之间,但不出现在最后一个菜单项之间

android - android webview 浏览器是否支持 html5 功能?

html - iPhone 上 Unicode 复选标记 2714 的颜色没有改变