1. 交互
  2. field-sizing(字段尺寸)

交互

field-sizing

用于控制表单控件尺寸的工具类。

ClassStyles
field-sizing-fixed
field-sizing: fixed;
field-sizing-content
field-sizing: content;

示例

基于内容的尺寸调整

使用 field-sizing-content 工具类可以让表单控件根据内容自动调整尺寸:

在下方输入框中输入内容以观察尺寸变化

<textarea class="field-sizing-content ..." rows="2">  Latex Salesman, Vanderlay Industries</textarea>

使用固定尺寸

使用 field-sizing-fixed 工具类可以让表单控件保持固定尺寸:

在下方输入框中输入内容以观察尺寸保持不变

<textarea class="field-sizing-fixed w-80 ..." rows="2">  Latex Salesman, Vanderlay Industries</textarea>

响应式设计

Prefix a field-sizing utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<input class="field-sizing-content md:field-sizing-fixed ..." />

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy