1. 滤镜
  2. 投影

滤镜

滤镜: drop-shadow()

将 drop-shadow 滤镜应用于元素的工具类.

ClassStyles
drop-shadow-xs
filter: drop-shadow(var(--drop-shadow-xs)); /* 0 1px 1px rgb(0 0 0 / 0.05) */
drop-shadow-sm
filter: drop-shadow(var(--drop-shadow-sm)); /* 0 1px 2px rgb(0 0 0 / 0.15) */
drop-shadow-md
filter: drop-shadow(var(--drop-shadow-md)); /* 0 3px 3px rgb(0 0 0 / 0.12) */
drop-shadow-lg
filter: drop-shadow(var(--drop-shadow-lg)); /* 0 4px 4px rgb(0 0 0 / 0.15) */
drop-shadow-xl
filter: drop-shadow(var(--drop-shadow-xl)); /* 0 9px 7px rgb(0 0 0 / 0.1) */
drop-shadow-2xl
filter: drop-shadow(var(--drop-shadow-2xl)); /* 0 25px 25px rgb(0 0 0 / 0.15) */
drop-shadow-none
filter: drop-shadow(0 0 #0000);
drop-shadow-(<custom-property>)
filter: drop-shadow(var(<custom-property>));
drop-shadow-[<value>]
filter: drop-shadow(<value>);

示例

基础示例

使用像 drop-shadow-smdrop-shadow-xl 的工具类为元素添加阴影:

drop-shadow-md

drop-shadow-lg

drop-shadow-xl

<svg class="drop-shadow-md ...">
<!-- ... -->
</svg>
<svg class="drop-shadow-lg ...">
<!-- ... -->
</svg>
<svg class="drop-shadow-xl ...">
<!-- ... -->
</svg>

这对于将阴影应用于不规则形状(如文本和 SVG 元素)非常有用。如果要将阴影应用于规则元素,您可能希望使用 盒子阴影

使用自定义值

Use the drop-shadow-[<value>] syntax to set the 投影阴影 based on a completely custom value:

<svg class="drop-shadow-[0_35px_35px_rgba(0,0,0,0.25)] ...">
<!-- ... -->
</svg>

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

<svg class="drop-shadow-(--my-drop-shadow) ...">
<!-- ... -->
</svg>

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

响应式设计

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

<svg class="drop-shadow-md md:drop-shadow-xl ...">
<!-- ... -->
</svg>

Learn more about using variants in the variants documentation.

自定义主题

Use the --drop-shadow-* theme variables to customize the 投影阴影 utilities in your project:

@theme {
--drop-shadow-3xl: 0 35px 35px rgba(0, 0, 0, 0.25);
}

Now the drop-shadow-3xl utility can be used in your markup:

<svg class="drop-shadow-3xl">
<!-- ... -->
</svg>

Learn more about customizing your theme in the theme documentation.