1. 变换
  2. 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