svg - SVG:标记以任何 svg 元素为目标
问题描述
我想在我的页面中定义一个<animate>
标签以<defs>
在多个页面上使用它<circle>
。
问题是:
如果我将
xlink:href
动画标签中的 但我不能在其他圈子上重复使用我的动画。我无法
xlink:href
从<animate>
标签中删除 并将其覆盖在 上<use>
,因为<use>
标签已经具有该属性(以动画为目标)。最后,如果我将
<use>
我的动画作为<circle>
标签的子项,则动画将不起作用。
所以我的问题:有没有办法 <animation>
在各种 SVG 元素上重用标签?
编辑:我想在<use>
. 例如:<use xlink:href="myAnim" cx="50" />
或 <use xlink:href="myAnim" to="50" />
解决方案
如果您打算在多个圆圈上使用相同的动画,为什么不将动画圆圈放入<defs>
并使用圆圈?
svg{border:1px solid}
<svg viewBox = "0 0 100 100" width="200">
<symbol viewBox="0 0 10 100" id="c">
<circle r="5" cy="35" cx="5" >
<animate
attributeName="cy"
attributeType="XML"
values="35;95;35"
dur="5s"
repeatCount="indefinite"/>
</circle>
</symbol>
<use xlink:href="#c" fill="red" width="10" />
<use xlink:href="#c" fill="gold" width="5" x="20" />
<use xlink:href="#c" fill="skyblue" width="7" x="40" />
</svg>
推荐阅读
- .net - 删除多对多关系
- python - 如何将参数传递给 pytest 夹具?
- python - 如何在Python中匹配当前日期和特定日期
- azure - 为 Azure 应用服务应用程序实施 Cookie 横幅
- flutter - 在 null 上调用了 getter 'visible'
- spring - CORS spring 安全过滤器与 WebMvcConfigurer.addCorsMappings
- c# - System.ArgumentException:“设置 DataSource 属性时无法修改项目集合。” C# Windows 窗体
- python - 在套接字中检索空文本
- asynchronous - 如何链接 ObservableObject?
- typescript - 打字稿:在组合类型中合并相似键的类型