D
D
DrunkMaster2017-08-02 15:17:57
SVG
DrunkMaster, 2017-08-02 15:17:57

How to anchor text to parent in SVG?

Example https://codepen.io/anon/pen/VzjJQK
Last g block:

<g id="g12">
    <title>Заголовок 12</title>
    <desc>Текст 12</desc>
      <path id="path16" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#231f20;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1" d="M 482.25,470.173 H 260.693 V 607.898 H 482.25 Z" />
    <text x="30" y="90"  fill="#ED6E46" font-size="100" font-family="'Leckerli One', cursive">Watermelon</text>
  </g>

It is clear that the starting point of the text is in this case the coordinates 30x90, the question is: how not to specify the coordinates manually, but to make the text automatically positioned inside the block g id="g12" aligned in width and height?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question