1. 滤镜
  2. 亮度

滤镜

backdrop-filter: brightness()

用于将背景亮度过滤器应用于元素的工具类。

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

示例

基本示例

使用像 backdrop-brightness-50backdrop-brightness-100 这样的工具类来控制元素的背景亮度:

backdrop-brightness-50

backdrop-brightness-150

<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-brightness-50 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-brightness-150 ..."></div>
</div>

使用自定义值

Use the backdrop-brightness-[<value>] syntax to set the 背景亮度 based on a completely custom value:

<div class="backdrop-brightness-[1.75] ...">
<!-- ... -->
</div>

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

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

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

响应式设计

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

<div class="backdrop-brightness-110 md:backdrop-brightness-150 ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.