SVG文本锚设置可移动文本元素 [英] SVG text-anchor setting makes the text element to move

查看:73
本文介绍了SVG文本锚设置可移动文本元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试设置SVG文本元素的文本锚. 但是当我这样做时,文本元素的位置正在改变.我读了它的"x"属性,但它保持不变.但是getBBox()给出了不同的值.

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.

我的问题: 如何重新定位文本元素?有什么方法可以设置BBox? 我正在使用JQuery和JQuery SVG

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

推荐答案

听起来您似乎误解了text-anchor属性的工作方式.它告诉渲染器应如何相对于使用xy指定的位置定位文本.如果您更改它,则文本的位置将相对于x& y.

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.

您可以在此处阅读其定义: http://www.w3.org/TR/SVG/text.html#AlignmentProperties

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

如何重新定位文本元素?

How do I reposition the text element?

您使用xy属性.您还可以使用transform属性.

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

有什么方法可以设置BBox?

is there any method to set the BBox?

不.边框是只读的.

这篇关于SVG文本锚设置可移动文本元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆