跳到主要内容
输入关键词开始搜索,↑ ↓ 选择,Enter 打开
没有找到匹配的文档

字重

用于控制字体粗细的工具,包括加粗、半粗、中等、正常和纤细粗细。

类名样式
.fw-lighterfont-weight: lighter;
.fw-lightfont-weight: 300;
.fw-normalfont-weight: 400;
.fw-mediumfont-weight: 500;
.fw-semiboldfont-weight: 600;
.fw-boldfont-weight: 700;
.fw-bolderfont-weight: bolder;

字体粗细

使用这些工具可以快速更改文本的font-weight。font-weight工具的缩写是.fw-*。

加粗文本。

更粗的字体(相对于父元素)。

半粗体文字。

中等重量的文本。

正常重量的文字。

轻量文本。

较轻的文本(相对于父元素)。

HTML
<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

字体粗细在 $font-weights 的 scss/_config.scss 映射中定义。CSS 自定义属性(--font-weight-*)由 scss/_root.scss 中的此映射生成,同一个映射为下面的 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
),