1. 滤镜
  2. 模糊

滤镜

filter: blur()

应用模糊滤镜到元素的实用工具。

ClassStyles
blur-xs
filter: blur(var(--blur-xs)); /* 4px */
blur-sm
filter: blur(var(--blur-sm)); /* 8px */
blur-md
filter: blur(var(--blur-md)); /* 12px */
blur-lg
filter: blur(var(--blur-lg)); /* 16px */
blur-xl
filter: blur(var(--blur-xl)); /* 24px */
blur-2xl
filter: blur(var(--blur-2xl)); /* 40px */
blur-3xl
filter: blur(var(--blur-3xl)); /* 64px */
blur-none
filter: ;
blur-(<custom-property>)
filter: blur(var(<custom-property>));
blur-[<value>]
filter: blur(<value>);

示例

基本示例

使用实用工具如 blur-smblur-lg 模糊一个元素:

blur-none

blur-sm

blur-lg

blur-2xl

<img class="blur-none" src="/img/mountains.jpg" />
<img class="blur-sm" src="/img/mountains.jpg" />
<img class="blur-lg" src="/img/mountains.jpg" />
<img class="blur-2xl" src="/img/mountains.jpg" />

使用自定义值

Use the blur-[<value>] syntax to set the blur based on a completely custom value:

<img class="blur-[2px] ..." src="/img/mountains.jpg" />

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

<img class="blur-(--my-blur) ..." src="/img/mountains.jpg" />

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

响应式设计

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

<img class="blur-none md:blur-lg ..." src="/img/mountains.jpg" />

Learn more about using variants in the variants documentation.

自定义主题

Use the --blur-* theme variables to customize the blur utilities in your project:

@theme {
--blur-2xs: 2px;
}

Now the blur-2xs utility can be used in your markup:

<img class="blur-2xs" src="/img/mountains.jpg" />

Learn more about customizing your theme in the theme documentation.