1. 变换
  2. rotate

变换

rotate

用于旋转元素的工具。

样式
rotate-none
rotate: none;
rotate-<number>
rotate: <number>deg;
-rotate-<number>
rotate: calc(<number>deg * -1);
rotate-(<custom-property>)
rotate: var(<custom-property>);
rotate-[<value>]
rotate: <value>;
rotate-x-<number>
transform: rotateX(<number>deg) var(--tw-rotate-y);
-rotate-x-<number>
transform: rotateX(-<number>deg) var(--tw-rotate-y);
rotate-x-(<custom-property>)
transform: rotateX(var(<custom-property>)) var(--tw-rotate-y);
rotate-x-[<value>]
transform: rotateX(<value>) var(--tw-rotate-y);
rotate-y-<number>
transform: var(--tw-rotate-x) rotateY(<number>deg);

示例(Examples)

¥Examples

基本示例(Basic example)

¥Basic example

使用 rotate-<number> 工具(如 rotate-45rotate-90)按度旋转元素:

¥Use rotate-<number> utilities like rotate-45 and rotate-90 to rotate an element by degrees:

rotate-45

rotate-90

rotate-210

<img class="rotate-45 ..." src="/img/mountains.jpg" />
<img class="rotate-90 ..." src="/img/mountains.jpg" />
<img class="rotate-210 ..." src="/img/mountains.jpg" />

使用负值(Using negative values)

¥Using negative values

使用 -rotate-<number> 工具(如 -rotate-45-rotate-90)按度逆时针旋转元素:

¥Use -rotate-<number> utilities like -rotate-45 and -rotate-90 to rotate an element counterclockwise by degrees:

-rotate-45

-rotate-90

-rotate-210

<img class="-rotate-45 ..." src="/img/mountains.jpg" />
<img class="-rotate-90 ..." src="/img/mountains.jpg" />
<img class="-rotate-210 ..." src="/img/mountains.jpg" />

在 3D 空间中旋转(Rotating in 3D space)

¥Rotating in 3D space

使用 rotate-x-<number>rotate-y-<number>rotate-z-<number> 工具(如 rotate-x-50-rotate-y-30rotate-z-45)一起在 3D 空间中旋转元素:

¥Use rotate-x-<number>, rotate-y-<number>, and rotate-z-<number> utilities like rotate-x-50, -rotate-y-30, and rotate-z-45 together to rotate an element in 3D space:

rotate-x-50

rotate-z-45

rotate-x-15

-rotate-y-30

rotate-y-25

rotate-z-30

<img class="rotate-x-50 rotate-z-45 ..." src="/img/mountains.jpg" />
<img class="rotate-x-15 -rotate-y-30 ..." src="/img/mountains.jpg" />
<img class="rotate-y-25 rotate-z-30 ..." src="/img/mountains.jpg" />

使用自定义值(Using a custom value)

¥Using a custom value

使用 rotate-[<value>] 语法 根据完全自定义的值设置 rotation

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

对于 CSS 变量,还可以使用 rotate-(<custom-property>) 语法:

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

这只是简写,用于 rotate-[var(<custom-property>)] 它会自动为你添加 var() 函数。

响应式设计(Responsive design)

¥Responsive design

rotate 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:

<img class="rotate-45 md:rotate-60 ..." src="/img/mountains.jpg" />

请参阅 变体文档 详细了解如何使用变体。

TailwindCSS v4.1 中文网 - 粤ICP备13048890号