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

不透明度工具在 scss/_utilities.scss 中的工具 API 中声明。Learn how to use the utilities 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,
  )
),