1. 变换
  2. 倾斜

变换

倾斜

用于通过变换倾斜元素的工具。

ClassStyles
skew-<number>
transform: skewX(<number>deg) skewY(<number>deg);
-skew-<number>
transform: skewX(-<number>deg) skewY(-<number>deg);
skew-(<custom-property>)
transform: skewX(var(<custom-property>)) skewY(var(<custom-property>));
skew-[<value>]
transform: skewX(<value>) skewY(<value>);
skew-x-<number>
transform: skewX(<number>deg));
-skew-x-<number>
transform: skewX(-<number>deg));
skew-x-(<custom-property>)
transform: skewX(var(<custom-property>));
skew-x-[<value>]
transform: skewX(<value>));
skew-y-<number>
transform: skewY(<number>deg);
-skew-y-<number>
transform: skewY(-<number>deg);
skew-y-(<custom-property>)
transform: skewY(var(<custom-property>));
skew-y-[<value>]
transform: skewY(<value>);

示例

基本示例

使用 skew-<number> 工具,例如 skew-4skew-10,在两个轴上倾斜元素:

skew-3

skew-6

skew-12

<img class="skew-3 ..." src="/img/mountains.jpg" />
<img class="skew-6 ..." src="/img/mountains.jpg" />
<img class="skew-12 ..." src="/img/mountains.jpg" />

使用负值

使用 -skew-<number> 工具,例如 -skew-4-skew-10,在两个轴上倾斜元素:

-skew-3

-skew-6

-skew-12

<img class="-skew-3 ..." src="/img/mountains.jpg" />
<img class="-skew-6 ..." src="/img/mountains.jpg" />
<img class="-skew-12 ..." src="/img/mountains.jpg" />

在x轴上倾斜

使用 skew-x-<number> 工具,例如 skew-x-4-skew-x-10,仅在x轴上倾斜元素:

-skew-x-12

skew-x-6

skew-x-12

<img class="-skew-x-12 ..." src="/img/mountains.jpg" />
<img class="skew-x-6 ..." src="/img/mountains.jpg" />
<img class="skew-x-12 ..." src="/img/mountains.jpg" />

在y轴上倾斜

使用 skew-y-<number> 工具,例如 skew-y-4-skew-y-10,仅在y轴上倾斜元素:

-skew-y-12

skew-y-6

skew-y-12

<img class="-skew-y-12 ..." src="/img/mountains.jpg" />
<img class="skew-y-6 ..." src="/img/mountains.jpg" />
<img class="skew-y-12 ..." src="/img/mountains.jpg" />

使用自定义值

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

<img class="skew-[3.142rad] ..." src="/img/mountains.jpg" />

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

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

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

响应式设计

Prefix skewX() and skewY() utilities with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<img class="skew-3 md:skew-12 ..." src="/img/mountains.jpg" />

Learn more about using variants in the variants documentation.