1. 交互
  2. 调整大小

Quick reference

属性
resize-noneresize: none;
resize-yresize: vertical;
resize-xresize: horizontal;
resizeresize: both;

基本用法(Basic usage)

全方位调整大小(Resizing in all directions)

使用 resize 使元素可以水平和垂直调整大小。

🌐 Use resize to make an element horizontally and vertically resizable.

Drag the textarea handle in the demo to see the expected behaviour

<textarea class="resize rounded-md"></textarea>

垂直调整大小(Resizing vertically)

使用 resize-y 使元素可以垂直调整大小。

🌐 Use resize-y to make an element vertically resizable.

Drag the textarea handle in the demo to see the expected behaviour

<textarea class="resize-y rounded-md"></textarea>

水平调整大小(Resizing horizontally)

使用 resize-x 使元素可以水平调整大小。

🌐 Use resize-x to make an element horizontally resizable.

Drag the textarea handle in the demo to see the expected behaviour

<textarea class="resize-x rounded-md"></textarea>

防止调整大小(Preventing resizing)

使用 resize-none 来防止元素被调整大小。

🌐 Use resize-none to prevent an element from being resizable.

Notice that the textarea handle is gone

<textarea class="resize-none rounded-md"></textarea>

有条件申请

悬停、聚焦及其他状态

Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:resize 仅在 hover 时应用 resize 工具。

<div class="resize-none hover:resize">
  <!-- ... -->
</div>

有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。

断点和媒体查询

你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:resize 仅在中等屏幕尺寸及以上时应用 resize 工具。

<div class="resize-none md:resize">
  <!-- ... -->
</div>

要了解更多信息,请查看有关 响应式设计暗黑模式、以及 其他媒体查询修饰符 的文档。