I have adobe illustrator. When I export graphic to svg, the text part looks like:
<style type="text/css">
.st6{fill:#FFFFFF;}
</style>
<text id="text2" transform="matrix(1 0 0 1 153.873 305.2743)" class="st6">Default text</text>
This text is aligned to center. Now I change text inside browser with javascript - so, replace "Default text" with "New text". This text is not aligned to center any more. If I change text, how can I achieve that it is always aligned to center? I have try with adding "text-align:center" to st6 class or adding this property to text element:
text-anchor="middle"
but doesn't work. Any idea?
One interesting other example which I don't understand. Here is part of svg template I have:
<g id="text_4">
<g>
<defs>
<rect id="SVGID_10_" x="9.96" y="273.53" width="170" height="15"/>
</defs>
<clipPath id="SVGID_11_">
<use xlink:href="#SVGID_10_" style="overflow:visible;"/>
</clipPath>
<g style="clip-path:url(#SVGID_11_);">
<text data-label="Text 4" text-anchor="middle" x="95" y="282.7" style="fill:#748B9E; font-family:'Merriweather'; font-size:8px;">2013 Riesling </text>
</g>
</g>
I can change text for example instead of "2013 Riesling" I can add "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" and text is still in the center.
Then I have removed all elements from this svg except text(so remove all g elements and clip path) only this left:
<text data-label="Text 4" text-anchor="middle" x="95" y="282.7" style="fill:#748B9E; font-family:'Merriweather'; font-size:8px;">2013 Riesling</text>
But template is still the same, nothing has changed if I view it inside browser. How is that possible? So, I can shorten size of SVG for 70%. And here text is always centered while in my template if I do the same it is not. Interesting.