aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/attribute/alignment-baseline/index.html
blob: e5ea1d818a1fad6201027fe6cf8327a170abe01f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
---
title: alignment-baseline
slug: Web/SVG/Attribute/alignment-baseline
tags:
  - SVG
  - SVG属性
  - 需要兼容性表
translation_of: Web/SVG/Attribute/alignment-baseline
---
<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG属性参考主页</a></p>

<p><code>alignment-baseline</code>属性指定了一个对象如何相对于它的父元素对齐。这个属性指定了该元素的基线对齐到相应的父元素的基线。举个例子,允许罗马文字中的字母表基线在字体大小发生变化时保持一致。它的默认值是baseline,与该<code>alignment-baseline</code>属性的计算值同名。</p>

<p>作为一个外观属性,它还可以直接作为CSS样式表内部的属性使用。请阅读{{ cssxref("alignment-baseline","CSS alignment-baseline") }}以了解更多信息。</p>

<h2 id="用法">用法</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="row">类别</th>
   <td>外观属性</td>
  </tr>
  <tr>
   <th scope="row"></th>
   <td><strong>auto</strong> | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | inherit</td>
  </tr>
  <tr>
   <th scope="row">可变性</th>
   <td>Yes</td>
  </tr>
  <tr>
   <th scope="row">规范文档</th>
   <td><a class="external" href="http://www.w3.org/TR/SVG11/text.html#AlignmentBaselineProperty">SVG 1.1 (2nd Edition)</a></td>
  </tr>
 </tbody>
</table>

<h2 id="示例">示例</h2>

<pre><code>&lt;?xml version="1.0"?&gt;
&lt;svg width="300" height="120" viewBox="0 0 300 120"
     xmlns="http://www.w3.org/2000/svg" version="1.1"&gt;

    &lt;!-- Materialisation of anchors --&gt;
    &lt;path d="M60,10 L60,110
             M30,10 L300,10
             M30,65 L300,65
             M30,110 L300,110
             " stroke="grey" /&gt;

    &lt;!-- Anchors in action --&gt;
    &lt;text alignment-baseline="hanging"
          x="60" y="10"&gt;A hanging&lt;/text&gt;

    &lt;text alignment-baseline="middle"
          x="60" y="65"&gt;A middle&lt;/text&gt;

    &lt;text alignment-baseline="baseline"
          x="60" y="110"&gt;A baseline&lt;/text&gt;

    &lt;!-- Materialisation of anchors --&gt;
    &lt;circle cx="60" cy="10" r="3" fill="red" /&gt;
    &lt;circle cx="60" cy="65" r="3" fill="red" /&gt;
    &lt;circle cx="60" cy="110" r="3" fill="red" /&gt;

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

<h2 id="元素">元素</h2>

<p>下列元素使用<code>alignment-baseline属性:</code></p>

<ul>
 <li>{{ SVGElement("tspan") }}</li>
 <li>{{ SVGElement("tref") }}</li>
 <li>{{ SVGElement("altGlyph") }}</li>
 <li>{{ SVGElement("textPath") }}</li>
</ul>

<p>如果对象要在别的元素中对齐(比如在{{ SVGElement("text") }}元素中),请阅读{{ SVGAttr("dominant-baseline") }}</p>

<h2 id="参见">参见</h2>

<ul>
 <li>{{ cssxref("alignment-baseline","CSS alignment-baseline") }}</li>
</ul>