aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/font-variant-position/index.html
blob: c150db874739b429c091238f0adc6ba67960b8a5 (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
93
94
95
96
97
98
99
100
101
102
103
---
title: font-variant-position
slug: Web/CSS/font-variant-position
translation_of: Web/CSS/font-variant-position
---
<div>{{CSSRef}}</div>

<p>The <strong><code>font-variant-position</code></strong> CSS property controls the use of alternate, smaller glyphs that are positioned as superscript or subscript.</p>

<p>The glyphs are positioned relative to the baseline of the font, which remains unchanged. These glyphs are typically used in {{HTMLElement("sub")}} and {{HTMLElement("sup")}} elements.</p>

<pre class="brush:css no-line-numbers">/* Keyword values */
font-variant-position: normal;
font-variant-position: sub;
font-variant-position: super;

/* Global values */
font-variant-position: inherit;
font-variant-position: initial;
font-variant-position: unset;
</pre>

<p>When the usage of these alternate glyphs is activated, if one character in the run doesn't have such a typographically-enhanced glyph, the whole set of characters of the run is rendered using a fallback method, synthesizing these glyphs.</p>

<p>These alternate glyphs share the same em-box and the same baseline as the rest of the font. They are merely graphically enhanced, and have no effect on the line-height and other box characteristics.</p>

<p>{{cssinfo}}</p>

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

<p>The <code>font-variant-position</code> property is specified as one of the keyword values listed below.</p>

<h3 id="可选值">可选值</h3>

<dl>
 <dt><code>normal</code></dt>
 <dd>Deactivates alternate superscript and subscript glyphs.</dd>
 <dt><code>sub</code></dt>
 <dd>Activates subscript alternate glyphs. If, in a given run, one such glyph is not available for a character, all the characters in the run are rendered using synthesized glyphs.</dd>
 <dt><code>super</code></dt>
 <dd>Activates superscript alternate glyphs. If, in a given run, one such glyph is not available for a character, all the characters in the run are rendered using synthesized glyphs.</dd>
</dl>

<h3 id="正式语法">正式语法</h3>

<pre class="syntaxbox">{{csssyntax}}</pre>

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

<h3 id="HTML">HTML</h3>

<pre class="brush:html">&lt;p class="normal"&gt;Normal!&lt;/p&gt;
&lt;p class="super"&gt;Super!&lt;/p&gt;
&lt;p class="sub"&gt;Sub!&lt;/p&gt;
</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush:css">p {
  display: inline;
}

.normal {
  font-variant-position: normal;
}

.super {
  font-variant-position: super;
}

.sub {
  font-variant-position: sub;
}
</pre>

<h3 id="Result">Result</h3>

<p>{{ EmbedLiveSample('Examples') }}</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">说明</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Fonts', '#propdef-font-variant-position', 'font-variant-position')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>



<p>{{Compat("css.properties.font-variant-position")}}</p>