1. 排版
  2. 文本装饰样式

Quick reference

Class
Properties
decoration-solidtext-decoration-style: solid;
decoration-doubletext-decoration-style: double;
decoration-dottedtext-decoration-style: dotted;
decoration-dashedtext-decoration-style: dashed;
decoration-wavytext-decoration-style: wavy;

基础用法

设置文本装饰样式

使用 decoration-* 实用程序来更改元素 text decoration 的样式。

decoration-solid

The quick brown fox jumps over the lazy dog.

decoration-double

The quick brown fox jumps over the lazy dog.

decoration-dotted

The quick brown fox jumps over the lazy dog.

decoration-dashed

The quick brown fox jumps over the lazy dog.

decoration-wavy

The quick brown fox jumps over the lazy dog.

<p class="underline decoration-solid ...">The quick brown fox...</p>
<p class="underline decoration-double ...">The quick brown fox...</p>
<p class="underline decoration-dotted ...">The quick brown fox...</p>
<p class="underline decoration-dashed ...">The quick brown fox...</p>
<p class="underline decoration-wavy ...">The quick brown fox...</p>

条件应用

悬停、聚焦和其他状态

Tailwind 允许您使用变体修饰符有条件地在不同状态下应用实用程序类。例如,使用 hover:decoration-dashed 来仅 在 hover应用 decoration-dashed.

<p class="underline hover:decoration-dashed">
  <!-- ... -->
</p>

详细了解, 请参考 Hover, Focus, & Other States 文档.

断点和媒体查询

您还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗模式、首选减少运动等。例如, 使用 md:decoration-dashed 来应用 decoration-dashed 程序,适用于中等屏幕尺寸及以上。

<p class="underline md:decoration-dashed">
  <!-- ... -->
</p>

进一步了解,请参考 响应式设计, 暗黑模式 媒体查询.