1. 排版
  2. font-stretch(字体拉伸)

排版

font-stretch

用于选择字体宽度的工具类。

ClassStyles
font-stretch-ultra-condensed
font-stretch: ultra-condensed; /* 50% */
font-stretch-extra-condensed
font-stretch: extra-condensed; /* 62.5% */
font-stretch-condensed
font-stretch: condensed; /* 75% */
font-stretch-semi-condensed
font-stretch: semi-condensed; /* 87.5% */
font-stretch-normal
font-stretch: normal; /* 100% */
font-stretch-semi-expanded
font-stretch: semi-expanded; /* 112.5% */
font-stretch-expanded
font-stretch: expanded; /* 125% */
font-stretch-extra-expanded
font-stretch: extra-expanded; /* 150% */
font-stretch-ultra-expanded
font-stretch: ultra-expanded; /* 200% */
font-stretch-<percentage>
font-stretch: <percentage>;
font-stretch-(<custom-property>)
font-stretch: var(<custom-property>);
font-stretch-[<value>]
font-stretch: <value>;

示例

基础示例

使用 font-stretch-condensedfont-stretch-expanded 等工具类来设置字体的宽度:

font-stretch-extra-condensed

The quick brown fox jumps over the lazy dog.

font-stretch-condensed

The quick brown fox jumps over the lazy dog.

font-stretch-normal

The quick brown fox jumps over the lazy dog.

font-stretch-expanded

The quick brown fox jumps over the lazy dog.

font-stretch-extra-expanded

The quick brown fox jumps over the lazy dog.

<p class="font-stretch-extra-condensed">The quick brown fox...</p><p class="font-stretch-condensed">The quick brown fox...</p><p class="font-stretch-normal">The quick brown fox...</p><p class="font-stretch-expanded">The quick brown fox...</p><p class="font-stretch-extra-expanded">The quick brown fox...</p>

此功能仅适用于具有多种宽度变体的字体,否则浏览器会选择最接近的匹配项。

使用百分比

使用 font-stretch-<percentage> 工具类(如 font-stretch-50%font-stretch-125%)通过百分比设置字体的宽度:

font-stretch-50%

The quick brown fox jumps over the lazy dog.

font-stretch-100%

The quick brown fox jumps over the lazy dog.

font-stretch-150%

The quick brown fox jumps over the lazy dog.

<p class="font-stretch-50%">The quick brown fox...</p><p class="font-stretch-100%">The quick brown fox...</p><p class="font-stretch-150%">The quick brown fox...</p>

使用自定义值

Use the font-stretch-[<value>] syntax to set the 字体宽度 based on a completely custom value:

<p class="font-stretch-[66.66%] ...">  Lorem ipsum dolor sit amet...</p>

For CSS variables, you can also use the font-stretch-(<custom-property>) syntax:

<p class="font-stretch-(--my-font-width) ...">  Lorem ipsum dolor sit amet...</p>

This is just a shorthand for font-stretch-[var(<custom-property>)] that adds the var() function for you automatically.

响应式设计

Prefix a font-stretch utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="font-stretch-normal md:font-stretch-expanded ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy