【发布时间】:2015-09-10 01:08:49
【问题描述】:
谁能给我一个示例,说明如何在 SVG 中垂直居中多行文本?我用谷歌搜索了很多对 alignment-baseline 和 dominant-baseline 的引用,但没有具体的例子可供我查看。
例如,在以下 SVG 中,TEXT 元素被其左上角锁定。文本在该 y 位置之后开始出现。如果我想让文本在那个 y 位置的上方和下方均匀分布,我需要做什么?
<text x="110" y="50" dy="0">
<tspan dy="0em" x="110" style="font-weight: bold; fill: rgb(74, 76, 77);">
<tspan x="110" dy="0em">This is my long quotation that will now wrap</tspan>
<tspan x="110" dy="1.1em">over multiple lines, maybe even two lines!</tspan>
<tspan x="110" dy="1.1em">Isn't that amazing?</tspan>
</tspan>
<tspan dy="1.5em" x="110" style="font-style: italic;">
Speaker, Speaker Description
</tspan>
</text>
(如果有帮助,我正在通过 D3 生成它)
【问题讨论】:
-
请提供一张现在的照片和你想要的东西。这将比阅读文本更有帮助。