Skip to main content Skip to docs navigation

阴影

使用 box-shadow 工具向元素添加或删除阴影。

示例

🌐 Examples

虽然在 Bootstrap 中组件的阴影默认是禁用的,可以通过 $enable-shadows 启用,但你也可以使用我们的 box-shadow 工具类快速添加或移除阴影。包括对 .shadow-none 的支持以及三种默认尺寸(这些尺寸有相应的变量以便匹配)。

🌐 While shadows on components are disabled by default in Bootstrap and can be enabled via $enable-shadows, you can also quickly add or remove a shadow with our box-shadow utility classes. Includes support for .shadow-none and three default sizes (which have associated variables to match).

No shadow
Small shadow
Regular shadow
Larger shadow
html
<div class="shadow-none p-3 mb-5 bg-body-tertiary rounded">No shadow</div>
<div class="shadow-sm p-3 mb-5 bg-body-tertiary rounded">Small shadow</div>
<div class="shadow p-3 mb-5 bg-body-tertiary rounded">Regular shadow</div>
<div class="shadow-lg p-3 mb-5 bg-body-tertiary rounded">Larger shadow</div>

CSS

Sass 变量

🌐 Sass variables

$box-shadow:                  0 .5rem 1rem rgba($black, .15);
$box-shadow-sm:               0 .125rem .25rem rgba($black, .075);
$box-shadow-lg:               0 1rem 3rem rgba($black, .175);
$box-shadow-inset:            inset 0 1px 2px rgba($black, .075);

Sass 工具 API

🌐 Sass utilities API

Shadow 工具在我们的工具 API scss/_utilities.scss 中声明。了解如何使用工具 API。

🌐 Shadow utilities are declared in our utilities API in scss/_utilities.scss. Learn how to use the utilities API.

"shadow": (
  property: box-shadow,
  class: shadow,
  values: (
    null: var(--#{$prefix}box-shadow),
    sm: var(--#{$prefix}box-shadow-sm),
    lg: var(--#{$prefix}box-shadow-lg),
    none: none,
  )
),