--- title: font-variant slug: Web/CSS/font-variant tags: - CSS - CSS Fonts - CSS Property - Reference translation_of: Web/CSS/font-variant ---
{{CSSRef}}

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

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

语法

font-variant: small-caps;
font-variant: common-ligatures small-caps;

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

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

正式语法

{{csssyntax}}

示例

HTML

<p class="normal">Firefox rocks!</p>
<p class="small">Firefox rocks!</p>

CSS

p.normal {
  font-variant: normal;
}
p.small {
  font-variant: small-caps;
}

结果

规范

{{cssinfo}}

Specification Status Comment
{{SpecName('CSS3 Fonts', '#propdef-font-variant', 'font-variant')}} {{Spec2('CSS3 Fonts')}} Made it a shorthand of the new font-variant-* properties.
{{SpecName('CSS2.1', 'fonts.html#propdef-font-variant', 'font-variant')}} {{Spec2('CSS2.1')}} No change
{{SpecName('CSS1', '#font-variant', 'font-variant')}} {{Spec2('CSS1')}} Initial definition

浏览器兼容性

{{Compat("css.properties.font-variant")}}

参见