1. 变换
  2. 变换样式

变换

transform-style

用于控制元素的子元素是否放置在3D空间中的工具。

ClassStyles
transform-3d
transform-style: preserve-3d;
transform-flat
transform-style: flat;

示例

基本示例

使用 transform-3d 将子元素定位在3D空间中:

transform-flat

1
2
3
4
5
6

transform-3d

1
2
3
4
5
6
<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.