aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/font-variant/index.html
blob: a01120c3c3d2f50532174f453cd617a46032de19 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: font-variant
slug: Web/CSS/font-variant
tags:
  - CSS
  - CSS Fonts
  - CSS Property
  - Reference
translation_of: Web/CSS/font-variant
---
<div>{{CSSRef}}</div>

<p><strong>font-variant</strong> 属性是{{cssxref("font-variant-caps")}}, {{cssxref("font-variant-numeric")}}, {{cssxref("font-variant-alternates")}}, {{cssxref("font-variant-ligatures")}}, {{cssxref("font-variant-east-asian")}}等属性的简写。你也可以使用简写 {{cssxref("font")}} 设定<code>font-variant</code>在CSS Level 2 (Revision 1)中的值(即<code>normal</code> 或 <code>small-caps</code>)。</p>

<div>{{EmbedInteractiveExample("pages/css/font-variant.html")}}</div>



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

<pre class="brush:css no-line-numbers">font-variant: small-caps;
font-variant: common-ligatures small-caps;

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

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

<dl>
 <dt><code>normal</code></dt>
 <dd>规定一个常规(normal)字型;每个非简写的属性的初始值都是normal。属于 <code>font-variant</code> 的非简写属性有:{{cssxref("font-variant-caps")}}, {{cssxref("font-variant-numeric")}}, {{cssxref("font-variant-alternates")}}, {{cssxref("font-variant-ligatures")}}{{cssxref("font-variant-east-asian")}}</dd>
 <dt><code>none</code></dt>
 <dd>{{cssxref("font-variant-ligatures")}}设定为 <code>none</code> ,将其他非简写属性的值设定为初始值<code>normal</code></dd>
 <dt><code>&lt;common-lig-values&gt;</code>, <code>&lt;discretionary-lig-values&gt;</code>, <code>&lt;historical-lig-values&gt;</code>, <code>&lt;contextual-alt-values&gt;</code></dt>
 <dd>规定与{{cssxref("font-variant-ligatures")}}属性相关的关键字,可能的值包括: <code>common-ligatures</code>, <code>no-common-ligatures</code>, <code>discretionary-ligatures</code>, <code>no-discretionary-ligatures</code>, <code>historical-ligatures</code>, <code>no-historical-ligatures</code>, <code>contextual</code> 和 <code>no-contextual</code></dd>
 <dt><code>stylistic()</code><code>historical-forms</code>, <code>styleset()</code>, <code>character-variant()</code>, <code>swash()</code>, <code>ornaments()</code>, <code>annotation()</code></dt>
 <dd>规定与{{cssxref("font-variant-alternates")}}属性相关的关键字和函数。</dd>
 <dt><code>small-caps</code>, <code>all-small-caps</code>, <code>petite-caps</code>, <code>all-petite-caps</code>, <code>unicase</code>, <code>titling-caps</code></dt>
 <dd>规定与{{cssxref("font-variant-caps")}} 属性相关的关键字和函数。</dd>
 <dt><code>&lt;numeric-figure-values&gt;</code>, <code>&lt;numeric-spacing-values&gt;</code>, <code>&lt;numeric-fraction-values&gt;</code>, <code>ordinal</code>, <code>slashed-zero</code></dt>
 <dd>规定与{{cssxref("font-variant-alternates")}}属性相关的关键字,可能的值包括:<code>lining-nums</code>, <code>oldstyle-nums</code>, <code>proportional-nums</code>, <code>tabular-nums</code>, <code>diagonal-fractions</code>, <code>stacked-fractions</code>, <code>ordinal</code> 和 <code>slashed-zero</code></dd>
 <dt><code>&lt;east-asian-variant-values&gt;</code>, <code>&lt;east-asian-width-values&gt;</code>, <code>ruby</code></dt>
 <dd>规定与{{cssxref("font-variant-east-asian")}}属性相关的关键字,可能的值包括:<code>jis78</code>, <code>jis83</code>, <code>jis90</code>, <code>jis04</code>, <code>simplified</code>, <code>traditional</code>, <code>full-width</code>, <code>proportional-width</code>, <code>ruby</code></dd>
 <dt>
 <h3 id="正式语法">正式语法</h3>
 </dt>
</dl>

{{csssyntax}}

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

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

<pre class="brush: html">&lt;p class="normal"&gt;Firefox rocks!&lt;/p&gt;
&lt;p class="small"&gt;Firefox rocks!&lt;/p&gt;
</pre>

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

<pre class="brush: css">p.normal {
  font-variant: normal;
}
p.small {
  font-variant: small-caps;
}
</pre>

<h3 id="结果">结果</h3>

<p><iframe class="live-sample-frame sample-code-frame" frameborder="0" id="frame_Example" src="https://mdn.mozillademos.org/en-US/docs/Web/CSS/font-variant$samples/Example?revision=1598093"></iframe></p>

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

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Fonts', '#propdef-font-variant', 'font-variant')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Made it a shorthand of the new <code>font-variant-*</code> properties.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'fonts.html#propdef-font-variant', 'font-variant')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>No change</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS1', '#font-variant', 'font-variant')}}</td>
   <td>{{Spec2('CSS1')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

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

<div>


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

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

<ul>
 <li>{{cssxref("text-transform")}}</li>
 <li>{{cssxref("text-combine-upright")}}</li>
 <li>{{cssxref("text-orientation")}}</li>
</ul>