1. 文字排版
  2. font-weight

文字排版

font-weight

用於控制元素字體粗細的實用程式。

類別樣式
font-thin
font-weight: 100;
font-extralight
font-weight: 200;
font-light
font-weight: 300;
font-normal
font-weight: 400;
font-medium
font-weight: 500;
font-semibold
font-weight: 600;
font-bold
font-weight: 700;
font-extrabold
font-weight: 800;
font-black
font-weight: 900;
font-(<自定義屬性>)
font-weight: var(<自定義屬性>);
font-[<值>]
font-weight: <值>;

範例

基本範例

使用 font-thinfont-bold 等實用程式來設定元素的字體粗細

font-light

The quick brown fox jumps over the lazy dog.

font-normal

The quick brown fox jumps over the lazy dog.

font-medium

The quick brown fox jumps over the lazy dog.

font-semibold

The quick brown fox jumps over the lazy dog.

font-bold

The quick brown fox jumps over the lazy dog.

<p class="font-light ...">The quick brown fox ...</p><p class="font-normal ...">The quick brown fox ...</p><p class="font-medium ...">The quick brown fox ...</p><p class="font-semibold ...">The quick brown fox ...</p><p class="font-bold ...">The quick brown fox ...</p>

使用自定義值

使用 font-[<值>] 語法 來設定字體粗細基於完全自定義的值

<p class="font-[1000] ...">  <!-- ... --></p>

對於 CSS 變數,您也可以使用 font-(<自定義屬性>) 語法

<p class="font-(--my-font-weight) ...">  <!-- ... --></p>

這只是 font-[var(<自定義屬性>)] 的簡寫,它會自動為您新增 var() 函數。

響應式設計

字首 font-weight 實用程式 加上像 md: 這樣的斷點變體,以僅在中等 螢幕尺寸及以上應用該實用程式

<p class="font-normal md:font-bold ...">  <!-- ... --></p>

變體文件中了解更多關於使用變體的信息。

自定義您的主題

使用 --font-* 主題變數來客製化您專案中的字體粗細 實用程式

@theme {  --font-extrablack: 1000; }

現在, font-extrablack 實用程式可以在您的標記中使用

<div class="font-extrablack">  <!-- ... --></div>

主題文件中了解更多關於自定義您的主題的信息。 主題文件中了解更多關於自定義您的主題的信息。.

版權所有 © 2025 Tailwind Labs Inc.·商標政策