滤镜
对元素应用背景滤镜的工具类。
Class | Styles |
---|---|
backdrop-filter-none | backdrop-filter: none; |
backdrop-filter-(<custom-property>) | backdrop-filter: var(<custom-property>); |
backdrop-filter-[<value>] | backdrop-filter: <value>; |
使用 backdrop-blur-xs
和 backdrop-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.