1. 尺寸
  2. 最小高度

尺寸

最小高度

设置元素最小高度的工具类。

ClassStyles
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-<number> 工具类,如 min-h-24min-h-64,根据间距比例设置元素的固定最小高度:

min-h-96
min-h-80
min-h-64
min-h-48
min-h-40
min-h-32
min-h-24
<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>

使用百分比

使用 min-h-fullmin-h-<fraction> 工具类,如 min-h-1/2min-h-2/5,为元素提供基于百分比的最小高度:

min-h-full
min-h-9/10
min-h-3/4
min-h-1/2
min-h-1/3
<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>

使用自定义值

Use the min-h-[<value>] syntax to set the 最小高度 based on a completely custom value:

<div class="min-h-[220px] ...">  <!-- ... --></div>

For CSS variables, you can also use the min-h-(<custom-property>) syntax:

<div class="min-h-(--my-min-height) ...">  <!-- ... --></div>

This is just a shorthand for min-h-[var(<custom-property>)] that adds the var() function for you automatically.

响应式设计

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

<div class="h-24 min-h-0 md:min-h-full ...">  <!-- ... --></div>

Learn more about using variants in the variants documentation.

自定义你的主题

The min-h-<number> utilities are driven by the --spacing theme variable, which can be customized in your own theme:

@theme {  --spacing: 1px; }

Learn more about customizing the spacing scale in the theme variable documentation.