--- title: font-variant-numeric slug: Web/CSS/font-variant-numeric translation_of: Web/CSS/font-variant-numeric ---
font-variant-numeric
CSS 属性控制数字,分数和序号标记的替代字形的使用。
font-variant-numeric: normal; font-variant-numeric: ordinal; font-variant-numeric: slashed-zero; font-variant-numeric: lining-nums; /* <numeric-figure-values> */ font-variant-numeric: oldstyle-nums; /* <numeric-figure-values> */ font-variant-numeric: proportional-nums; /* <numeric-spacing-values> */ font-variant-numeric: tabular-nums; /* <numeric-spacing-values> */ font-variant-numeric: diagonal-fractions; /* <numeric-fraction-values> */ font-variant-numeric: stacked-fractions; /* <numeric-fraction-values> */ font-variant-numeric: oldstyle-nums stacked-fractions; /* Global values */ font-variant-numeric: inherit; font-variant-numeric: initial; font-variant-numeric: unset;
此属性以以下两种方式之一指定:
normal
normal
下列特性均不启用。
ordinal
ordn
。slashed-zero
lining-nums
启用内衬数字显示。使数字全部对齐到基线。等同于 OpenType 特性 lnum
。oldstyle-nums
启用旧式数字显示。部分数字如 3、4、7、9 会有下沉。等同于 OpenType 特性 onum
。proportional-nums
启用比例数字显示。使数字变成基于字形本身形状下的特定宽度表现。等同于 OpenType 特性 pnum
。tabular-nums
启用表格数字显示。使数字等宽,易于像表格那样对齐。等同于 OpenType 特性 tnum
。diagonal-fractions
启用斜角分数显示。使分子和分母变成像下标字,并用变长的斜线分隔。等同于 OpenType 特性 frac。stacked-fractions
启用标准分数显示。使分子在上,分母在下,并用水平线分隔。等同于 OpenType 特性 afrc。{{cssinfo}}
<p class="ordinal">1st, 2nd, 3rd, 4th, 5th</p>
/* This example uses the Source Sans Pro OpenType font, developed by Adobe and used here under the terms of the SIL Open Font License, Version 1.1: http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web */ @font-face { font-family: "Source Sans Pro"; font-style: normal; font-weight: 400; src: url("https://mdn.mozillademos.org/files/15757/SourceSansPro-Regular.otf") format("opentype"); } .ordinal { font-variant-numeric: ordinal; font-family: "Source Sans Pro"; }
{{EmbedLiveSample('Setting_ordinal_numeric_forms')}}
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS3 Fonts', '#propdef-font-variant-numeric', 'font-variant-numeric')}} | {{Spec2('CSS3 Fonts')}} | Initial definition |
{{Compat("css.properties.font-variant-numeric")}}