1. 滤镜
  2. 反转

滤镜

backdrop-filter: invert()

用于将 backdrop 反转滤镜应用于元素的工具。

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

示例

基本示例

使用像 backdrop-invertbackdrop-invert-65 这样的工具来控制元素背景的颜色反转:

backdrop-invert-0

backdrop-invert-65

backdrop-invert

<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert-0 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert-65 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
<div class="bg-white/30 backdrop-invert ..."></div>
</div>

使用自定义值

Use the backdrop-invert-[<value>] syntax to set the 反转背景 based on a completely custom value:

<div class="backdrop-invert-[.25] ...">
<!-- ... -->
</div>

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

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

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

响应式设计

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

<div class="backdrop-invert-0 md:backdrop-invert ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.