1. 排版
  2. 文本装饰线

排版

text-decoration-line

控制文本装饰的实用工具。

ClassStyles
underline
text-decoration-line: underline;
overline
text-decoration-line: overline;
line-through
text-decoration-line: line-through;
no-underline
text-decoration-line: none;

示例

添加下划线文本

使用 underline 实用工具为元素的文本添加下划线:

敏捷的棕色狐狸跳过懒惰的狗。

<p class="underline">敏捷的棕色狐狸...</p>

为文本添加上划线

使用 overline 实用工具为元素的文本添加上划线:

敏捷的棕色狐狸跳过懒惰的狗。

<p class="overline">敏捷的棕色狐狸...</p>

为文本添加删除线

使用 line-through 实用工具为元素的文本添加删除线:

敏捷的棕色狐狸跳过懒惰的狗。

<p class="line-through">敏捷的棕色狐狸...</p>

从文本中移除线

使用 no-underline 实用工具从元素的文本中移除线:

敏捷的棕色狐狸跳过懒惰的狗。

<p class="no-underline">敏捷的棕色狐狸...</p>

鼠标悬停时应用

Prefix a text-decoration-line utility with a variant like hover:* to only apply the utility in that state:

将鼠标悬停在文本上以查看预期效果

敏捷的 棕色狐狸 跳过懒惰的狗。
<p>敏捷的 <a href="..." class="no-underline hover:underline ...">棕色狐狸</a> 跳过懒惰的狗。</p>

Learn more about using variants in the variants documentation.

响应式设计

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

<a class="no-underline md:underline ..." href="...">  <!-- ... --></a>

Learn more about using variants in the variants documentation.