滤镜
应用于元素的背景模糊滤镜的工具类。
Class | Styles |
---|---|
backdrop-blur-xs | backdrop-filter: blur(var(--blur-xs)); /* 4px */ |
backdrop-blur-sm | backdrop-filter: blur(var(--blur-sm)); /* 8px */ |
backdrop-blur-md | backdrop-filter: blur(var(--blur-md)); /* 12px */ |
backdrop-blur-lg | backdrop-filter: blur(var(--blur-lg)); /* 16px */ |
backdrop-blur-xl | backdrop-filter: blur(var(--blur-xl)); /* 24px */ |
backdrop-blur-2xl | backdrop-filter: blur(var(--blur-2xl)); /* 40px */ |
backdrop-blur-3xl | backdrop-filter: blur(var(--blur-3xl)); /* 64px */ |
backdrop-blur-none | backdrop-filter: ; |
backdrop-blur-(<custom-property>) | backdrop-filter: blur(var(<custom-property>)); |
backdrop-blur-[<value>] | backdrop-filter: blur(<value>); |
使用诸如 backdrop-blur-sm
和 backdrop-blur-lg
的工具类来控制元素的背景模糊:
backdrop-blur-none
backdrop-blur-sm
backdrop-blur-md
<div class="bg-[url(/img/mountains.jpg)]"> <div class="bg-white/30 backdrop-blur-none ..."></div></div><div class="bg-[url(/img/mountains.jpg)]"> <div class="bg-white/30 backdrop-blur-sm ..."></div></div><div class="bg-[url(/img/mountains.jpg)]"> <div class="bg-white/30 backdrop-blur-md ..."></div></div>
Use the backdrop-blur-[<value>]
syntax to set the 背景模糊 based on a completely custom value:
<div class="backdrop-blur-[2px] ..."> <!-- ... --></div>
For CSS variables, you can also use the backdrop-blur-(<custom-property>)
syntax:
<div class="backdrop-blur-(--my-backdrop-blur) ..."> <!-- ... --></div>
This is just a shorthand for backdrop-blur-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a backdrop-filter: blur()
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="backdrop-blur-none md:backdrop-blur-lg ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.
Use the --blur-*
theme variables to customize the 背景模糊 utilities in your project:
@theme { --blur-2xs: 2px; }
Now the backdrop-blur-2xs
utility can be used in your markup:
<div class="backdrop-blur-2xs"> <!-- ... --></div>
Learn more about customizing your theme in the theme documentation.