bootstrap中的$spacer是什么意思?

9 sass bootstrap-4

我是引导新手。我在引导程序上找到了这个文档:

https://getbootstrap.com/docs/4.3/utilities/spacing/
Run Code Online (Sandbox Code Playgroud)

这里写的是,当我们写例如 mt-1 时,这意味着:

1 - (by default) for classes that set the margin or padding to $spacer * .25
Run Code Online (Sandbox Code Playgroud)

在这种情况下 $spacer * .25 意味着什么?

Zim*_*Zim 9

$spacer是一个 SASS 变量。默认情况下它的值为1rem. 因此 mt-1 是margin-top:.25rem;

6 个间距单位 (0-5) 中每一个的值均源自 $spacers SASS 映射变量...

$spacers: (
    0: 0,
    1: ($spacer * .25),
    2: ($spacer * .5),
    3: $spacer,
    4: ($spacer * 1.5),
    5: ($spacer * 3)
)
Run Code Online (Sandbox Code Playgroud)

结果...

mt-1 = .25rem
mt-2 = .5rem
mt-3 = 1rem
mt-4 = 1.5rem
mt-5 = 3rem
Run Code Online (Sandbox Code Playgroud)

相关:如何在 Bootstrap 4 上使用间距实用程序类