1. 过渡与动画
  2. 过渡延迟

过渡与动画

transition-delay

用于控制 CSS 转换延迟的工具类。

ClassStyles
delay-<number>
transition-delay: <number>ms;
delay-(<custom-property>)
transition-delay: var(<custom-property>);
delay-[<value>]
transition-delay: <value>;

示例

基本示例

使用诸如 delay-150delay-700 的工具类来设置元素的转换延迟(以毫秒为单位):

悬停每个按钮以查看预期的行为

delay-150

delay-300

delay-700

<button class="transition delay-150 duration-300 ease-in-out ...">按钮 A</button>
<button class="transition delay-300 duration-300 ease-in-out ...">按钮 B</button>
<button class="transition delay-700 duration-300 ease-in-out ...">按钮 C</button>

使用自定义值

Use the delay-[<value>] syntax to set the 转换延迟 based on a completely custom value:

<button class="delay-[1s,250ms] ...">
<!-- ... -->
</button>

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

<button class="delay-(--my-delay) ...">
<!-- ... -->
</button>

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

响应式设计

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

<button class="delay-150 md:delay-300 ...">
<!-- ... -->
</button>

Learn more about using variants in the variants documentation.