过渡与动画
用于控制 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.