alignment-baseline - SVG: Scalable Vector Graphics 编辑

The alignment-baseline attribute specifies how an object is aligned with respect to its parent. This property specifies which baseline of this element is to be aligned with the corresponding baseline of the parent. For example, this allows alphabetic baselines in Roman text to stay aligned across font size changes. It defaults to the baseline with the same name as the computed value of the alignment-baseline property.

Note: As a presentation attribute alignment-baseline can be used as a CSS property.

As a presentation attribute, it can be applied to any element but it has effect only on the following four elements: <tspan>, <tref>, <altGlyph>, and <textPath>

Usage notes

Valueauto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | top | center | bottom
Default valueauto
AnimatableYes
auto This deprecated API should no longer be used, but will probably still work.
The value is the dominant-baseline of the script to which the character belongs - i.e., use the dominant-baseline of the parent.
baseline
Uses the dominant baseline choice of the parent. Matches the box’s corresponding baseline to that of its parent.
before-edge This deprecated API should no longer be used, but will probably still work.
The alignment-point of the object being aligned is aligned with the "before-edge" baseline of the parent text content element.
text-bottom
Matches the bottom of the box to the top of the parent’s content area.
text-before-edge

The alignment-point of the object being aligned is aligned with the "text-before-edge" baseline of the parent text content element.

Note: This keyword may be mapped to text-top.

middle
Aligns the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
central
Matches the box’s central baseline to the central baseline of its parent.
after-edge This deprecated API should no longer be used, but will probably still work.

The alignment-point of the object being aligned is aligned with the "after-edge" baseline of the parent text content element.

text-top
Matches the top of the box to the top of the parent’s content area.
text-after-edge

The alignment-point of the object being aligned is aligned with the "text-after-edge" baseline of the parent text content element.

Note: This keyword may be mapped to text-bottom.

ideographic
Matches the box’s ideographic character face under-side baseline to that of its parent.
alphabetic
Matches the box’s alphabetic baseline to that of its parent.
hanging

The alignment-point of the object being aligned is aligned with the "hanging" baseline of the parent text content element.

mathematical
Matches the box’s mathematical baseline to that of its parent.
top

Aligns the top of the aligned subtree with the top of the line box.

center
Aligns the center of the aligned subtree with the center of the line box.
bottom
Aligns the bottom of the aligned subtree with the bottom of the line box.

SVG 2 introduces some changes to the definition of this property. In particular: the values auto, before-edge, and after-edge have been removed. For backwards compatibility, text-before-edge may be mapped to text-top and text-after-edge to text-bottom. Neither text-before-edge nor text-after-edge should be used with the vertical-align property.

Example

<svg width="300" height="120" viewBox="0 0 300 120"
     xmlns="http://www.w3.org/2000/svg">

    <!-- Materialisation of anchors -->
    <path d="M60,10 L60,110
             M30,10 L300,10
             M30,65 L300,65
             M30,110 L300,110
             " stroke="grey" />

    <!-- Anchors in action -->
    <text alignment-baseline="hanging"
          x="60" y="10">A hanging</text>

    <text alignment-baseline="middle"
          x="60" y="65">A middle</text>

    <text alignment-baseline="baseline"
          x="60" y="110">A baseline</text>

    <!-- Materialisation of anchors -->
    <circle cx="60" cy="10" r="3" fill="red" />
    <circle cx="60" cy="65" r="3" fill="red" />
    <circle cx="60" cy="110" r="3" fill="red" />

<style><![CDATA[
text{
    font: bold 36px Verdana, Helvetica, Arial, sans-serif;
}
]]></style>
</svg>

For object alignment in other elements (such as <text>), see dominant-baseline.

Specifications

SpecificationStatusComment
CSS Inline Layout
The definition of 'alignment-baseline' in that specification.
Working DraftNo change
Scalable Vector Graphics (SVG) 2
The definition of 'alignment-baseline' in that specification.
Candidate RecommendationRefers to the definition in CSS Inline Layout and notes the changes to auto, before-edge, after-edge, text-before-edge, and text-after-edge
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'alignment-baseline' in that specification.
RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:120 次

字数:11722

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文