Transitions & Animation
Utilities to control the behavior of CSS transitions.
Class | Styles |
---|---|
transition-normal | transition-behavior: normal; |
transition-discrete | transition-behavior: allow-discrete; |
Use the transition-discrete
utility to start transitions when changing properties with a discrete set of values, such as elements that change from hidden
to block
:
Interact with the checkboxes to see the expected behavior
<label class="peer ..."> <input type="checkbox" checked /></label><button class="hidden transition-all not-peer-has-checked:opacity-0 peer-has-checked:block ..."> I hide</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 ..."> I fade out</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.
Tailwind CSS 中文网(本网站)的目标是为中文开发者提供准确、及时的 Tailwind CSS 中文文档
Tailwind CSS 中文文档由本网站维护人员共同翻译,采用 MIT 开源协议发布
本网站与 tailwindcss.com 及 Tailwind Labs Inc. 并无从属关系
Tailwind 商标由 Tailwind Labs Inc. 所有
京ICP备15031610号-8