1. 字体排印
  2. text-underline-offset

字体排印

text-underline-offset

用于控制文本下划线偏移的实用工具。

类名样式
underline-offset-<number>
text-underline-offset: <number>px;
-underline-offset-<number>
text-underline-offset: calc(<number>px * -1);
underline-offset-auto
text-underline-offset: auto;
underline-offset-(<custom-property>)
text-underline-offset: var(<custom-property>);
underline-offset-[<value>]
text-underline-offset: <value>;

示例

基本示例

使用 underline-offset-<number> 实用工具 (如 underline-offset-2underline-offset-4) 来更改文本下划线的偏移

underline-offset-1

The quick brown fox jumps over the lazy dog.

underline-offset-2

The quick brown fox jumps over the lazy dog.

underline-offset-4

The quick brown fox jumps over the lazy dog.

underline-offset-8

The quick brown fox jumps over the lazy dog.

<p class="underline underline-offset-1">The quick brown fox...</p>
<p class="underline underline-offset-2">The quick brown fox...</p>
<p class="underline underline-offset-4">The quick brown fox...</p>
<p class="underline underline-offset-8">The quick brown fox...</p>

使用自定义值

使用 underline-offset-[<value>] 语法 来设置文本下划线偏移基于完全自定义的值

<p class="underline-offset-[3px] ...">
Lorem ipsum dolor sit amet...
</p>

对于 CSS 变量,您还可以使用 underline-offset-(<custom-property>) 语法

<p class="underline-offset-(--my-underline-offset) ...">
Lorem ipsum dolor sit amet...
</p>

这只是一个简写形式,用于 underline-offset-[var(<custom-property>)] 它会自动为您添加 var() 函数。

响应式设计

前缀a text-underline-offset 实用工具 使用断点变体 (如 md:) 以仅在中等 屏幕尺寸及以上时应用该实用工具

<p class="underline md:underline-offset-4 ...">
Lorem ipsum dolor sit amet...
</p>

了解更多关于在 变体文档 中使用变体的信息。

版权所有 © 2025 Tailwind Labs Inc.·商标政策