【问题标题】:Is there a command to move the whole SVG path to a new position?是否有将整个 SVG 路径移动到新位置的命令?
【发布时间】:2021-12-07 15:42:03
【问题描述】:

是否有命令将整个 SVG 路径移动到新位置,而不是向路径的每个点添加偏移量?

【问题讨论】:

  • 继续阅读:组和“使用”元素

标签: javascript svg


【解决方案1】:

感谢sehe的评论。解决方法是:将路径包裹成

<g transform="translate(offset_x,offset_y)"></g>

【讨论】:

  • ...或者只是将transform 属性放在&lt;path&gt; 本身上。
【解决方案2】:
<path transform="translate(x, y)" d="....">

如果您的路径已经有变换并且您不想干扰它们:

<g transform="translate(x, y)">
    <path transform="..." d="....">
</g>

盗用 Phrogz 的评论和 Powerboy 的回答。

【讨论】:

    猜你喜欢
    • 2017-05-07
    • 2011-09-29
    • 1970-01-01
    • 2022-01-20
    • 1970-01-01
    • 2011-11-14
    • 2013-04-21
    • 1970-01-01
    • 2012-04-01
    相关资源
    最近更新 更多