过渡与动画
用于控制 CSS 过渡行为的工具类。
Class | Styles |
---|---|
transition-normal | transition-behavior: normal; |
transition-discrete | transition-behavior: allow-discrete; |
使用 transition-discrete
工具类在改变具有离散值集合的属性时启动过渡效果,例如元素从 hidden
变为 block
的情况:
与复选框交互以查看预期行为
<label class="peer ..."> <input type="checkbox" checked /></label><button class="hidden transition-all not-peer-has-checked:opacity-0 peer-has-checked:block ..."> 我会隐藏</button><label class="peer ..."> <input type="checkbox" checked /></label><button class="hidden transition-all transition-discrete not-peer-has-checked:opacity-0 peer-has-checked:block ..."> 我会淡出</button>
Prefix a transition-behavior
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<button class="transition-discrete md:transition-normal ..."> <!-- ... --></button>
Learn more about using variants in the variants documentation.