1. 排版
  2. font-stretch

排版

font-stretch

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

样式
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>;

示例(Examples)

¥Examples

基本示例(Basic example)

¥Basic example

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

¥Use utilities like font-stretch-condensed and font-stretch-expanded to set the width of a font face:

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>

这仅适用于具有多种可用宽度变化的字体,否则浏览器将选择最接近的匹配。

¥This only applies to fonts that have multiple width variations available, otherwise the browser selects the closest match.

使用百分比(Using percentages)

¥Using percentages

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

¥Use font-stretch-<percentage> utilities like font-stretch-50% and font-stretch-125% to set the width of a font face using a percentage:

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>

使用自定义值(Using a custom value)

¥Using a custom value

使用 font-stretch-[<value>] 语法 根据完全自定义的值设置 font width

<p class="font-stretch-[66.66%] ...">  <!-- ... --></p>

对于 CSS 变量,还可以使用 font-stretch-(<custom-property>) 语法:

<p class="font-stretch-(--my-font-width) ...">  <!-- ... --></p>

这只是简写,用于 font-stretch-[var(<custom-property>)] 它会自动为你添加 var() 函数。

响应式设计(Responsive design)

¥Responsive design

font-stretch 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:

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

请参阅 变体文档 详细了解如何使用变体。

TailwindCSS v4.0 中文网 - 粤ICP备13048890号