尺寸
用于设置元素最大高度的实用工具。
| 类名 | 样式 |
|---|---|
max-h-<number> | max-height: calc(var(--spacing) * <number>); |
max-h-<fraction> | max-height: calc(<fraction> * 100%); |
max-h-none | max-height: none; |
max-h-px | max-height: 1px; |
max-h-full | max-height: 100%; |
max-h-screen | max-height: 100vh; |
max-h-dvh | max-height: 100dvh; |
max-h-dvw | max-height: 100dvw; |
max-h-lvh | max-height: 100lvh; |
max-h-lvw | max-height: 100lvw; |
max-h-svh | max-height: 100svh; |
max-h-svw | max-height: 100svw; |
max-h-min | max-height: min-content; |
max-h-max | max-height: max-content; |
max-h-fit | max-height: fit-content; |
max-h-(<custom-property>) | max-height: var(<custom-property>); |
max-h-[<value>] | max-height: <value>; |
使用 max-h-<number> 实用工具,例如 max-h-24 和 max-h-64,根据间距比例将元素设置为固定的最大高度
<div class="h-96 ..."> <div class="h-full max-h-80 ...">max-h-80</div> <div class="h-full max-h-64 ...">max-h-64</div> <div class="h-full max-h-48 ...">max-h-48</div> <div class="h-full max-h-40 ...">max-h-40</div> <div class="h-full max-h-32 ...">max-h-32</div> <div class="h-full max-h-24 ...">max-h-24</div></div>使用 max-h-full 或 max-h-<fraction> 实用工具,例如 max-h-1/2 和 max-h-2/5,为元素提供基于百分比的最大高度
<div class="h-96 ..."> <div class="h-full max-h-9/10 ...">max-h-9/10</div> <div class="h-full max-h-3/4 ...">max-h-3/4</div> <div class="h-full max-h-1/2 ...">max-h-1/2</div> <div class="h-full max-h-1/4 ...">max-h-1/4</div> <div class="h-full max-h-full ...">max-h-full</div></div>使用 max-h-[<value>] 语法 来设置最大高度基于完全自定义的值
<div class="max-h-[220px] ..."> <!-- ... --></div>对于 CSS 变量,您还可以使用 max-h-(<custom-property>) 语法
<div class="max-h-(--my-max-height) ..."> <!-- ... --></div>这只是 max-h-[var(<custom-property>)] 的简写形式,它会自动为您添加 var() 函数。
前缀a max-height 实用工具 与断点变体(如 md:)一起使用,以仅在中等 屏幕尺寸及以上尺寸应用该实用工具
<div class="h-48 max-h-full md:max-h-screen ..."> <!-- ... --></div>了解有关在变体文档中使用变体的更多信息。
的 max-h-<number> 实用工具由 --spacing 主题变量驱动,该变量可以在您自己的主题中自定义
@theme { --spacing: 1px; }了解有关在主题变量文档中自定义间距比例的更多信息。