| Class | Styles |
|---|---|
| .fw-lighter | font-weight: lighter; |
| .fw-light | font-weight: 300; |
| .fw-normal | font-weight: 400; |
| .fw-medium | font-weight: 500; |
| .fw-semibold | font-weight: 600; |
| .fw-bold | font-weight: 700; |
| .fw-bolder | font-weight: bolder; |
字体粗细
使用这些工具类快速更改文本的 font-weight。font-weight 工具类缩写为 .fw-*。
Bold text.
Bolder weight text (relative to the parent element).
Semibold weight text.
Medium weight text.
Normal weight text.
Light weight text.
Lighter weight text (relative to the parent element).
<p class="fw-bold">Bold text.</p>
<p class="fw-bolder">Bolder weight text (relative to the parent element).</p>
<p class="fw-semibold">Semibold weight text.</p>
<p class="fw-medium">Medium weight text.</p>
<p class="fw-normal">Normal weight text.</p>
<p class="fw-light">Light weight text.</p>
<p class="fw-lighter">Lighter weight text (relative to the parent element).</p>CSS
Sass map
字体粗细在 scss/_config.scss 的 $font-weights map 中定义。CSS 自定义属性(--font-weight-*)由该 map 在 scss/_root.scss 中生成,同一个 map 也为下方的 Sass 工具类 API 提供支持。
$font-weights: ();
// stylelint-disable-next-line scss/dollar-variable-default
$font-weights: defaults(
(
lighter: lighter,
light: 300,
normal: 400,
medium: 500,
semibold: 600,
bold: 700,
bolder: bolder
),
$font-weights
);
Sass 工具类 API
字体粗细工具类在我们的工具类 API 中声明,位于 scss/_utilities.scss。了解如何使用工具类 API。
"font-weight": (
property: font-weight,
class: fw,
values: $font-weights
),