相关疑难解决方法(0)

SVG 嵌套 <svg> 与组

我知道在 SVG 中有两种方法可以将形状组合在一起并将它们定位为一个集合:嵌套<svg>标记和<g>分组。但是,我看不出它们之间有太大区别。例如,以下两段代码产生完全相同的结果:

使用组(jsfiddle)https : //jsfiddle.net/8q4on01m/5/

<svg width="5000" height="5000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <g transform="translate(200 200)">
    <rect x="0" y="0" height="100" width="100" style="fill: yellow"></rect>

    <rect x="0" y="0" height="100" width="100" style="fill: green" transform="rotate(45) translate(200 100)"></rect>

    <rect x="0" y="0" height="100" width="100" style="fill: red" transform="translate(200 100)"></rect>
  </g>
</svg>
Run Code Online (Sandbox Code Playgroud)

使用<svg> (jsfiddle)

<svg width="5000" height="5000" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <svg x="200" y="200">
    <rect x="0" y="0" height="100" width="100" style="fill: yellow"></rect>

    <rect x="0" y="0" height="100" width="100" style="fill: green" transform="rotate(45) translate(200 100)"></rect>

    <rect x="0" …
Run Code Online (Sandbox Code Playgroud)

svg

12
推荐指数
1
解决办法
8031
查看次数

标签 统计

svg ×1