javascript SVG - 如何设置文本行高
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29829277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SVG - how to set text line-height
提问by DogBot
It seems line-height is the one CSS property absent from svg text. The best resource on SVG I have found is: Jenkov.com SVG Tutorials and there is no mention of it, neither could I find mention of it on MDN.
似乎 line-height 是 svg 文本中缺少的一个 CSS 属性。我找到的关于 SVG 的最佳资源是:Jenkov.com SVG Tutorials并且没有提到它,我也没有在 MDN 上找到它。
So if anyone can shed definitive light on this or share a technique. I am basically interested in the spacing between lines of text that wrap, not independent text elements.
因此,如果有人可以对此进行明确说明或分享技术。我基本上对环绕的文本行之间的间距感兴趣,而不是独立的文本元素。
Thanks
谢谢
回答by DanMan
SVG 1.1 (officially) only supports single line text, hence no line-height
setting.
SVG 1.1(官方)只支持单行文本,因此没有line-height
设置。
I've just tried creating a block of text in Inkscape, and it's using a flowRoot
element (containing a flowPara
element with the actual text in it). Then the flowRoot
element actually has line-height
assigned to it (in %).
我刚刚尝试在 Inkscape 中创建一个文本块,它使用了一个flowRoot
元素(包含一个包含flowPara
实际文本的元素)。然后flowRoot
元素实际上已line-height
分配给它(以%为单位)。
I don't know how wide-spread support for that way is, since it used to be part of SVG 1.2. You might also want to have a look here: Auto line-wrapping in SVG text
我不知道这种方式的支持有多广泛,因为它曾经是 SVG 1.2 的一部分。您可能还想看看这里:SVG 文本中的自动换行