--- title: font-stretch slug: Web/CSS/font-stretch translation_of: Web/CSS/font-stretch ---
{{CSSRef}}
font-stretch
属性为字体定义一个正常或经过伸缩变形的字体外观,这个属性并不会通过伸展/缩小而改变字体的几何外形,如{{cssxref("font-feature-settings")}}和{{cssxref("font-variant")}}属性,它仅仅意味着当有多种字体可供选择时,会为字体选择最适合的大小。
Note: If the font provides several faces, the one fitting the best with the value of the font-stretch
property is chosen. E.g. On OS X, in addition to the more common Bold, Regular, Italic, and BoldItalic faces, the "Helvetica Neue" font proposes a second set of faces with condensed, that is shrunk, characters: Condensed. Browsers supporting font-stretch
will use the condensed faces for the value ultra-condensed
to semi-condensed
and the normal faces for the other (normal
and all expanded values).
If the font has no condensed or expanded faces, like the default "Times New Roman" on Mac OS, font-stretch
will not have any visible effect as the only suitable face will be used in all cases.:
{{cssinfo}}
/* Keyword values */ font-stretch: ultra-condensed; font-stretch: extra-condensed; font-stretch: condensed; font-stretch: semi-condensed; font-stretch: normal; font-stretch: semi-expanded; font-stretch: expanded; font-stretch: extra-expanded; font-stretch: ultra-expanded; /* Global values */ font-stretch: inherit; font-stretch: initial; font-stretch: unset;
normal
semi-condensed
, condensed
, extra-condensed
, ultra-condensed
semi-expanded
, expanded
, extra-expanded
, ultra-expanded
Font stretch values are interpolated in discrete steps. The interpolation happens as though the ordered values are equally spaced real numbers; the result is rounded to the nearest value, with values exactly halfway between two values rounded towards the later value, that is the most expanded one.
<div class="ultra stretch"> This is text with the font extremely expanded</div> <div class="stretch"> This is text with the font stretched</div> <div class="normal"> This is text without font stretching</div> <div class="condensed"> This is text with the font condensed</div> <div class="ultra condensed"> This is text with the font extremely condensed</div>
.ultra.stretch{font-stretch: ultra-expanded;} .stretch {font-stretch: expanded;} .normal {font-stretch: normal;} .condensed {font-stretch: condensed;} .ultra.condensed {font-stretch: ultra-condensed;}
{{ EmbedLiveSample('Example', '500', '', '', 'Web/CSS/font-stretch') }}
Specification | Status | Comment |
---|---|---|
{{ SpecName('CSS3 Fonts', '#propdef-font-stretch', 'font-stretch') }} | {{ Spec2('CSS3 Fonts') }} | Initial definition |
The CSS property font-stretch
was initially defined in CSS 2, but dropped in CSS 2.1 due to lack of implementation experience. It has been newly defined in CSS 3.
{{ CompatibilityTable() }}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 48.0 | {{CompatVersionUnknown}} | {{ CompatGeckoDesktop("9.0") }} | 9.0 | 35.0 | {{ CompatNo() }} |
Feature | Android | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{ CompatNo() }} | {{CompatVersionUnknown}} | {{ CompatGeckoMobile("9.0") }} | {{ CompatUnknown() }} | {{ CompatNo() }} | {{ CompatNo() }} |