简体   繁体   中英

embedding SVG in SVG

I couldn't find the way how to embed two SVGs into SVG document. I need to do it with ability of code which would manipulate with both child SVG-s, and would like to have independent coordinates on both of those areas. I don't like to do it in HTML, because I consider it too limiting comparing to SVG. Many thanks!

An SVG document fragment consists of any number of SVG elements contained within an 'svg' element.

Basically:

<svg …>
  <svg id="a" …>…</svg>
  <svg id="b" …>…</svg>
</svg>
<svg>
...
     <image x="..." y="..." width="..." height="..." xlink:href="path/to/your/file.svg" ></image>
...
</svg>

One of solution is '[parent svg] - [g] - [child svg]' structure.

<svg>
    <g transform="translate(-,-)">
        <svg>
            ...
        </svg>
    </g>
</svg>

You can set the cordinate of child svg as transform(translate) of g element.

demo:
http://hitokun-s.github.io/old/demo/path-between-two-svg.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM