1. 滤镜
  2. 背景滤镜

滤镜

背景滤镜

对元素应用背景滤镜的工具类。

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

示例

基本示例

使用 backdrop-blur-xsbackdrop-grayscale 等工具类为元素的背景应用滤镜:

backdrop-blur-xs

backdrop-grayscale

组合效果

<div class="bg-[url(/img/mountains.jpg)] ...">
<div class="backdrop-blur-xs ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)] ...">
<div class="backdrop-grayscale ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)] ...">
<div class="backdrop-blur-xs backdrop-grayscale ..."></div>
</div>

您可以组合以下背景滤镜工具类:模糊亮度对比度灰度色相旋转反转不透明度饱和度怀旧

移除滤镜

使用 backdrop-filter-none 工具类移除应用于元素的所有背景滤镜:

<div class="backdrop-blur-md backdrop-brightness-150 md:backdrop-filter-none"></div>

使用自定义值

Use the backdrop-filter-[<value>] syntax to set the 背景滤镜 based on a completely custom value:

<div class="backdrop-filter-[url('filters.svg#filter-id')] ...">
<!-- ... -->
</div>

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

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

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

在悬停时应用

Prefix a backdrop-filter utility with a variant like hover:* to only apply the utility in that state:

<div class="backdrop-blur-sm hover:backdrop-filter-none ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.

响应式设计

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

<div class="backdrop-blur-sm md:backdrop-filter-none ...">
<!-- ... -->
</div>

Learn more about using variants in the variants documentation.