尺寸
min-height
用于设置元素最小高度的工具。
| 类 | 样式 |
|---|---|
min-h-<number> | min-height: calc(var(--spacing) * <number>); |
min-h-<fraction> | min-height: calc(<fraction> * 100%); |
min-h-px | min-height: 1px; |
min-h-full | min-height: 100%; |
min-h-screen | min-height: 100vh; |
min-h-dvh | min-height: 100dvh; |
min-h-dvw | min-height: 100dvw; |
min-h-lvh | min-height: 100lvh; |
min-h-lvw | min-height: 100lvw; |
min-h-svw | min-height: 100svw; |
min-h-svh | min-height: 100svh; |
min-h-auto | min-height: auto; |
min-h-min | min-height: min-content; |
min-h-max | min-height: max-content; |
min-h-fit | min-height: fit-content; |
min-h-lh | min-height: 1lh; |
min-h-(<custom-property>) | min-height: var(<custom-property>); |
min-h-[<value>] | min-height: <value>; |
示例(Examples)
¥Examples
基本示例(Basic example)
¥Basic example
使用 min-h-<number> 工具(如 min-h-24 和 min-h-64)根据间距比例将元素设置为固定的最小高度:
¥Use min-h-<number> utilities like min-h-24 and min-h-64 to set an element to a fixed minimum height based on the spacing scale:
<div class="h-20 ..."> <div class="min-h-80 ...">min-h-80</div> <div class="min-h-64 ...">min-h-64</div> <div class="min-h-48 ...">min-h-48</div> <div class="min-h-40 ...">min-h-40</div> <div class="min-h-32 ...">min-h-32</div> <div class="min-h-24 ...">min-h-24</div></div>使用百分比(Using a percentage)
¥Using a percentage
使用 min-h-full 或 min-h-<fraction> 工具(如 min-h-1/2 和 min-h-2/5)为元素提供基于百分比的最小高度:
¥Use min-h-full or min-h-<fraction> utilities like min-h-1/2, and min-h-2/5 to give an element a percentage-based minimum height:
<div class="min-h-full ...">min-h-full</div><div class="min-h-9/10 ...">min-h-9/10</div><div class="min-h-3/4 ...">min-h-3/4</div><div class="min-h-1/2 ...">min-h-1/2</div><div class="min-h-1/3 ...">min-h-1/3</div>使用自定义值(Using a custom value)
¥Using a custom value
使用 min-h-[<value>] 语法 根据完全自定义的值设置 minimum height:
<div class="min-h-[220px] ..."> <!-- ... --></div>对于 CSS 变量,还可以使用 min-h-(<custom-property>) 语法:
<div class="min-h-(--my-min-height) ..."> <!-- ... --></div>这只是简写,用于 min-h-[var(<custom-property>)] 它会自动为你添加 var() 函数。
响应式设计(Responsive design)
¥Responsive design
在 min-height 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:
<div class="h-24 min-h-0 md:min-h-full ..."> <!-- ... --></div>请参阅 变体文档 详细了解如何使用变体。
自定义主题(Customizing your theme)
¥Customizing your theme
该 min-h-<number> 工具由 --spacing 主题变量驱动,可以在你自己的主题中进行自定义:
@theme { --spacing: 1px; }在主题变量文档中了解有关自定义间距比例的更多信息。