假设我有SVG文件:
<svg width="1024" height="768" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<text x='20' y='60' style="font-size: 60px">b</text>
<text x='100' y='60' style="font-size: 60px">a</text>
</svg>我想以某种方式将a和b的顶部对齐。实际上,我希望我的定位是根据roofline而不是baseline!
发布于 2012-09-03 23:14:17
alignment-baseline属性就是您要查找的属性,它可以采用以下值
auto | baseline | before-edge | text-before-edge |
middle | central | after-edge | text-after-edge |
ideographic | alphabetic | hanging | mathematical |
inherit来自w3c的描述
此属性指定对象相对于其父对象的对齐方式。此属性指定此元素的哪个基线要与父元素的相应基线对齐。例如,这允许罗马文本中的字母基线在字体大小更改时保持对齐。它默认为与alignment-baseline属性的计算值同名的基线。也就是说,“表意”对齐点在块行进方向上的位置是“表意”基线在被对齐对象的基线表中的位置。
W3C Source
不幸的是,虽然这是实现目标的“正确”方法,但似乎Firefox并没有为SVG Text Module ('SVG in Firefox' MDN Documentation)实现很多表示属性。
发布于 2013-04-14 17:19:13
根据SVG规范,alignment-baseline只适用于<tspan>、<textPath>、<tref>和<altGlyph>。我的理解是,它被用来从它们上面的<text>对象中偏移它们。我想你要找的是dominant-baseline。
dominant-baseline的可能值为:
auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge | inherit
有关每个可能值的详细信息,请查看the W3C recommendation for the property。
发布于 2014-03-04 17:36:47
attr(“主导基线”,“中心”)
https://stackoverflow.com/questions/12250403
复制相似问题