Skip to content
全部文档

field-sizing

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

快速参考

属性
field-sizing-fixedfield-sizing: fixed;
field-sizing-contentfield-sizing: content;

示例

根据内容调整尺寸

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

html
<!-- [!code classes:field-sizing-content] -->
<textarea class="field-sizing-content ..." rows="2">
  Latex Salesman, Vanderlay Industries
</textarea>

使用固定尺寸

使用 field-sizing-fixed 工具类,让表单控件使用固定尺寸:

html
<!-- [!code classes:field-sizing-fixed] -->
<textarea class="field-sizing-fixed w-80 ..." rows="2">
  Latex Salesman, Vanderlay Industries
</textarea>

响应式设计

使用 md: 等断点变体为 field-sizing 工具类添加前缀,使其仅在中等及以上屏幕尺寸生效:

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

变体文档 中了解如何使用变体。

文档译文以 MIT 协议授权;原文版权归 Tailwind Labs。湘ICP备2026005453号-2