1. 排版
  2. 字体粗细

排版

字体粗细

用于控制元素字体粗细的工具类。

ClassStyles
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-(<custom-property>)
font-weight: var(<custom-property>);
font-[<value>]
font-weight: <value>;

示例

基本示例

使用像 font-thinfont-bold 的工具类来设置元素的字体粗细:

font-light

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

font-normal

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

font-medium

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

font-semibold

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

font-bold

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

<p class="font-light ...">这只敏捷的棕色狐狸 ...</p><p class="font-normal ...">这只敏捷的棕色狐狸 ...</p><p class="font-medium ...">这只敏捷的棕色狐狸 ...</p><p class="font-semibold ...">这只敏捷的棕色狐狸 ...</p><p class="font-bold ...">这只敏捷的棕色狐狸 ...</p>

使用自定义值

Use the font-[<value>] syntax to set the 字体粗细 based on a completely custom value:

<p class="font-[1000] ...">  Lorem ipsum dolor sit amet...</p>

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

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

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

响应式设计

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

<p class="font-normal md:font-bold ...">  Lorem ipsum dolor sit amet...</p>

Learn more about using variants in the variants documentation.

自定义主题

Use the --font-weight-* theme variables to customize the 字体粗细 utilities in your project:

@theme {  --font-weight-超黑: 1000; }

Now the font-超黑 utility can be used in your markup:

<div class="font-超黑">  <!-- ... --></div>

Learn more about customizing your theme in the theme documentation.