Harikrishnan
Harikrishnan

Reputation: 3802

SVG text-anchor setting makes the text element to move

Hello I am trying to set the text-anchor of an SVG text element. But when I do that, the text elements position is changing. I read its "x" attribute but it remains same. but getBBox() gives different values.

My question: How do I reposition the text element? is there any method to set the BBox? I am using JQuery and JQuery SVG

Upvotes: 0

Views: 920

Answers (1)

Paul LeBeau
Paul LeBeau

Reputation: 101800

It sounds like you are misunderstanding how the text-anchor attribute works. It tells the renderer how the text should be positioned relative to the poisition you specify with x and y. If you change it, the position of the text will change relative to x & y.

You can read its definition here: http://www.w3.org/TR/SVG/text.html#AlignmentProperties

How do I reposition the text element?

You use the x and y attributes. You can also use the transform attribute.

is there any method to set the BBox?

No. The bounding box is read-only.

Upvotes: 1

Related Questions