【发布时间】:2019-07-06 10:55:13
【问题描述】:
我想要制作一个小 svg 绘图,它由几个 SVG 元素组成。我希望能够将它们一起制作动画,就好像它们是同一件事一样。
到目前为止,我已经将它们组合在一起,并在每个 SVG 的末尾放置了一个单独的动画,如下所示:
<g id="buildings">
<rect fill="#aad4ff" height="22" width="90" x="223.5" y="376.5">
<animate attributeType="XML" attributeName="y" from="376.5" to="373" begin="mouseover" end="mouseout" dur="500ms"/>
</rect>
<rect fill="#aad4ff" height="117" width="113" x="110.5" y="281.5">
<animate attributeType="XML" at . . .
</g>
正如你所看到的,我为每个 svg 设置了
我的问题是:在引用一组 SVG 时如何使用动画?
<g id="something">
<ellipse cx="46.78408" cy="425.59942" fill="#ff5656" rx="15" ry="16"/>
<ellipse cx="50" cy="437" fill="#ff5656" rx="25" ry="10"/>
<animate attributeType="XML" attributeName="cx" from="47" to="646" repeatCount="indefinite" dur="10s"/>
</g>
我想为组内的所有 SVG 元素使用一条动画线,但这种编写方式似乎不起作用。
PS - 这是一个项目,我不允许使用 CSS,如果这可以在 HTML 中完成,那将是最好的。
【问题讨论】:
标签: html animation svg grouping svg-animate