变换
用于控制元素的子元素是否放置在3D空间中的工具。
Class | Styles |
---|---|
transform-3d | transform-style: preserve-3d; |
transform-flat | transform-style: flat; |
使用 transform-3d
将子元素定位在3D空间中:
transform-flat
transform-3d
<div class="size-20 transform-flat ..."> <div class="translate-z-12 rotate-x-0 bg-sky-300/75 ...">1</div> <div class="-translate-z-12 rotate-y-180 bg-sky-300/75 ...">2</div> <div class="translate-x-12 rotate-y-90 bg-sky-300/75 ...">3</div> <div class="-translate-x-12 -rotate-y-90 bg-sky-300/75 ...">4</div> <div class="-translate-y-12 rotate-x-90 bg-sky-300/75 ...">5</div> <div class="translate-y-12 -rotate-x-90 bg-sky-300/75 ...">6</div></div><div class="size-20 transform-3d ..."> <div class="translate-z-12 rotate-x-0 bg-sky-300/75 ...">1</div> <div class="-translate-z-12 rotate-y-180 bg-sky-300/75 ...">2</div> <div class="translate-x-12 rotate-y-90 bg-sky-300/75 ...">3</div> <div class="-translate-x-12 -rotate-y-90 bg-sky-300/75 ...">4</div> <div class="-translate-y-12 rotate-x-90 bg-sky-300/75 ...">5</div> <div class="translate-y-12 -rotate-x-90 bg-sky-300/75 ...">6</div></div>
如果没有这个设置,任何子元素将只在2D空间中进行变换,而不是在3D空间中。
Prefix a transform-style
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="transform-3d md:transform-flat ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.