1. 排版
  2. 文本装饰颜色

排版

text-decoration-color

用于控制文本装饰颜色的工具类。

ClassStyles
decoration-inherit
text-decoration-color: inherit;
decoration-current
text-decoration-color: currentColor;
decoration-transparent
text-decoration-color: transparent;
decoration-black
text-decoration-color: var(--color-black); /* #000 */
decoration-white
text-decoration-color: var(--color-white); /* #fff */
decoration-red-50
text-decoration-color: var(--color-red-50); /* oklch(97.1% 0.013 17.38) */
decoration-red-100
text-decoration-color: var(--color-red-100); /* oklch(93.6% 0.032 17.717) */
decoration-red-200
text-decoration-color: var(--color-red-200); /* oklch(88.5% 0.062 18.334) */
decoration-red-300
text-decoration-color: var(--color-red-300); /* oklch(80.8% 0.114 19.571) */
decoration-red-400
text-decoration-color: var(--color-red-400); /* oklch(70.4% 0.191 22.216) */

示例

基本示例

使用类似于 decoration-sky-500decoration-pink-500 的工具类来改变元素的 文本装饰 颜色:

我是德里克,一名来自塔图因的星际工程师。我喜欢在 我的公司,Inc工作。在工作之余,我喜欢 观看飞船赛车 并进行 光剑 打斗。

<p>  我是德里克,一名来自塔图因的星际工程师。我喜欢在 <a class="underline decoration-sky-500">我的公司,Inc</a> 工作。在工作之余,我喜欢 <a class="underline decoration-pink-500">观看飞船赛车</a> 并进行 <a class="underline decoration-indigo-500">光剑</a> 打斗。</p>

改变不透明度

使用颜色不透明度修饰符来控制元素的文本装饰颜色的不透明度:

我是德里克,一名来自塔图因的星际工程师。我喜欢在 我的公司,Inc工作。在工作之余,我喜欢 观看飞船赛车 并进行 光剑 打斗。

<p>  我是德里克,一名来自塔图因的星际工程师。我喜欢在 <a class="underline decoration-sky-500/30">我的公司,Inc</a> 工作。在工作之余,我喜欢 <a class="underline decoration-pink-500/30">观看飞船赛车</a> 并进行 <a class="underline decoration-indigo-500/30">光剑</a> 打斗。</p>

使用自定义值

Use the decoration-[<value>] syntax to set the 文本装饰颜色 based on a completely custom value:

<p class="decoration-[#50d71e] ...">  Lorem ipsum dolor sit amet...</p>

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

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

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

在悬停时应用

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

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

那只 快速的棕色狐狸 跳过懒狗。
<p>那只 <a href="..." class="underline hover:decoration-pink-500 ...">快速的棕色狐狸</a> 跳过懒狗。</p>

Learn more about using variants in the variants documentation.

响应式设计

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

<p class="underline decoration-sky-600 md:decoration-blue-400 ...">  Lorem ipsum dolor sit amet...</p>

Learn more about using variants in the variants documentation.

自定义主题

Use the --color-* theme variables to customize the color utilities in your project:

@theme {  --color-regal-blue: #243c5a; }

Now the decoration-regal-blue utility can be used in your markup:

<p class="decoration-regal-blue">  Lorem ipsum dolor sit amet...</p>

Learn more about customizing your theme in the theme documentation.