1. 变换
  2. transform(变换)

变换

transform

用于元素变换的工具类。

ClassStyles
transform-(<custom-property>)
transform: var(<custom-property>);
transform-[<value>]
transform: <value>;
transform-none
transform: none;
transform-gpu
transform: translateZ(0) var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y);
transform-cpu
transform: var(--tw-rotate-x) var(--tw-rotate-y) var(--tw-rotate-z) var(--tw-skew-x) var(--tw-skew-y);

示例

硬件加速

当你的动画效果在 GPU 渲染下比 CPU 表现更好时,可以通过添加 transform-gpu 工具类强制启用硬件加速:

<div class="scale-150 transform-gpu">  <!-- ... --></div>

如果需要有条件地撤销此设置,可以使用 transform-cpu 工具类强制切换回 CPU 渲染。

移除变换效果

使用 transform-none 工具类可以一次性移除元素上的所有变换效果:

<div class="skew-y-3 md:transform-none">  <!-- ... --></div>

使用自定义值

Use the transform-[<value>] syntax to set the transform based on a completely custom value:

<div class="transform-[matrix(1,2,3,4,5,6)] ...">  <!-- ... --></div>

For CSS variables, you can also use the transform-(<custom-property>) syntax:

<div class="transform-(--my-transform) ...">  <!-- ... --></div>

This is just a shorthand for transform-[var(<custom-property>)] that adds the var() function for you automatically.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy