1. 变换
  2. 缩放

变换

scale

用于缩放元素的工具。

ClassStyles
scale-none
scale: none;
scale-<number>
scale: <number>% <number>%;
-scale-<number>
scale: calc(<number>% * -1) calc(<number>% * -1);
scale-(<custom-property>)
scale: var(<custom-property>) var(<custom-property>);
scale-[<value>]
scale: <value>;
scale-x-<number>
scale: <number>% var(--tw-scale-y);
-scale-x-<number>
scale: calc(<number>% * -1) var(--tw-scale-y);
scale-x-(<custom-property>)
scale: var(<custom-property>) var(--tw-scale-y);
scale-x-[<value>]
scale: <value> var(--tw-scale-y);
scale-y-<number>
scale: var(--tw-scale-x) <number>%;

示例

基本示例

使用 scale-<number> 工具,如 scale-75scale-150,按原始大小的百分比缩放一个元素:

scale-75

scale-100

scale-125

<img class="scale-75 ..." src="/img/mountains.jpg" />
<img class="scale-100 ..." src="/img/mountains.jpg" />
<img class="scale-125 ..." src="/img/mountains.jpg" />

在 x 轴上缩放

使用 scale-x-<number> 工具,如 scale-x-75-scale-x-150,按原始宽度的百分比在 x 轴上缩放一个元素:

scale-x-75

scale-x-100

scale-x-125

<img class="scale-x-75 ..." src="/img/mountains.jpg" />
<img class="scale-x-100 ..." src="/img/mountains.jpg" />
<img class="scale-x-125 ..." src="/img/mountains.jpg" />

在 y 轴上缩放

使用 scale-y-<number> 工具,如 scale-y-75-scale-y-150,按原始高度的百分比在 y 轴上缩放一个元素:

scale-y-75

scale-y-100

scale-y-125

<img class="scale-y-75 ..." src="/img/mountains.jpg" />
<img class="scale-y-100 ..." src="/img/mountains.jpg" />
<img class="scale-y-125 ..." src="/img/mountains.jpg" />

使用负值

使用 -scale-<number>-scale-x-<number>-scale-y-<number> 工具,如 -scale-x-75-scale-125,按原始大小的百分比镜像并缩小一个元素:

-scale-x-75

-scale-100

-scale-y-125

<img class="-scale-x-75 ..." src="/img/mountains.jpg" />
<img class="-scale-100 ..." src="/img/mountains.jpg" />
<img class="-scale-y-125 ..." src="/img/mountains.jpg" />

使用自定义值

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

<img class="scale-[1.7] ..." src="/img/mountains.jpg" />

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

<img class="scale-(--my-scale) ..." src="/img/mountains.jpg" />

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

在悬停时应用

Prefix a scale utility with a variant like hover:* to only apply the utility in that state:

<img class="scale-95 hover:scale-120 ..." src="/img/mountains.jpg" />

Learn more about using variants in the variants documentation.