Tailwind CSS - 文字裝飾



Tailwind CSS **文字裝飾** 包含實用程式類,這些類可以快速輕鬆地新增和調整 HTML 元素中的文字裝飾,而無需自定義 CSS。

Tailwind CSS 文字裝飾類

以下是 Tailwind CSS 文字裝飾類的列表,其中包括控制文字視覺樣式的屬性。

CSS 屬性
underline text-decoration-line: underline;
overline text-decoration-line: overline;
line-through text-decoration-line: line-through;
no-underline text-decoration-line: none;

Tailwind CSS 文字裝飾類的功能

  • **underline:** 此類在文字下方新增一條線。
  • **overline:** 此類在文字上方新增一條線。
  • **line-through:** 此類在文字中間繪製一條線。
  • **no-underline:** 此類刪除文字中的任何下劃線裝飾。

Tailwind CSS 文字裝飾類示例

以下是 Tailwind CSS 文字裝飾類的示例,這些示例顯示瞭如何使用不同的裝飾(如下劃線、上劃線、刪除線和無下劃線)來設定文字樣式。

應用文字裝飾

此示例演示瞭如何使用 Tailwind CSS 文字裝飾類在 HTML 元素中設定文字裝飾樣式。

示例

 
<!DOCTYPE html>
<html lang="en">
<head> 
   <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="p-4">
    <h1 class="text-2xl font-bold mb-4">
        Tailwind CSS List Style Position
    </h1> 
    <p> Underline class</p>
    <p class="underline text-2xl mb-4">
        This text uses the underline class.
    </p>
     <p>Overline class</p>
     <p class="overline text-2xl mb-4">
        This text uses the overline class.
    </p>
     <p>Line-through class</p>
    <p class="line-through text-2xl mb-4 ">
        This text uses the line-through class.
    </p>
     <p> No-underline class</p>
    <p class="no-underline text-2xl">
        This text uses the no-underline class.
    </p>
</body>

</html>

懸停時條件文字裝飾

此示例演示瞭如何有條件地應用 Tailwind CSS 文字裝飾類,使用帶有修飾符的實用程式類來控制不同的狀態。例如,“**hover:underline**”在懸停時對文字應用下劃線。

示例

<!DOCTYPE html>
<html lang="en">
<head> 
   <script src="https://cdn.tailwindcss.com"></script>
</head>

<body class="p-4">
    <h1 class="text-2xl font-bold mb-4">
        Tailwind CSS List Style Position
    </h1> 
    <h2 class="text-2xl mb-4">Hover to toggle line</h2>
    <p class="underline mb-6 hover:no-underline">
        Text is underlined by default.
    </p>
        <p class="overline mb-6 hover:no-underline"> 
        Text has an overline by default.
    </p>
    <p class="line-through mb-6 hover:underline">
        Text has a line through it by default.
    </p>
    <p class="no-underline mb-4 hover:underline">
        Text has no underline by default.
    </p>
</body>

</html>
廣告