1. 滤镜
  2. 不透明度

滤镜

backdrop-filter: opacity()

应用于元素的背景模糊不透明度滤镜的工具类。

ClassStyles
backdrop-opacity-<number>
backdrop-filter: opacity(<number>%);
backdrop-opacity-(<custom-property>)
backdrop-filter: opacity(var(<custom-property>));
backdrop-opacity-[<value>]
backdrop-filter: opacity(<value>);

示例

基础示例

使用 backdrop-opacity-50backdrop-opacity-75 等工具类来控制应用于元素的所有背景模糊滤镜的不透明度:

backdrop-opacity-10

backdrop-opacity-60

backdrop-opacity-95

<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert backdrop-opacity-10 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert backdrop-opacity-60 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert backdrop-opacity-95 ..."></div>
</div>

使用自定义值

Use the backdrop-opacity-[<value>] syntax to set the 背景滤镜不透明度 based on a completely custom value:

<div class="backdrop-opacity-[.15] ...">
<!-- ... -->
</div>

For CSS variables, you can also use the backdrop-opacity-(<custom-property>) syntax:

<div class="backdrop-opacity-(--my-backdrop-filter-opacity) ...">
<!-- ... -->
</div>

This is just a shorthand for backdrop-opacity-[var(<custom-property>)] that adds the var() function for you automatically.

响应式设计

Prefix a backdrop-filter: opacity() utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="backdrop-opacity-100 md:backdrop-opacity-60 ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.