1. Transforms
  2. transform

Transforms

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.

版权所有 © 2025 Tailwind Labs Inc.·商标政策