Skip to main content Skip to docs navigation
Added in v5.1

不透明度

控制元素的不透明度。

opacity 属性设置元素的不透明度。 不透明度描述了透明度的级别,其中 1 完全不透明,.5 可见度为 50%,0 完全透明。

🌐 The opacity property sets the opacity level for an element. The opacity level describes the transparency level, where 1 is not transparent at all, .5 is 50% visible, and 0 is completely transparent.

使用 .opacity-{value} 工具设置元素的 opacity

🌐 Set the opacity of an element using .opacity-{value} utilities.

100%
75%
50%
25%
0%
<div class="opacity-100">...</div>
<div class="opacity-75">...</div>
<div class="opacity-50">...</div>
<div class="opacity-25">...</div>
<div class="opacity-0">...</div>

CSS

Sass 工具 API

🌐 Sass utilities API

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

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

"opacity": (
  property: opacity,
  values: (
    0: 0,
    25: .25,
    50: .5,
    75: .75,
    100: 1,
  )
),