Sizing
用於設定元素最大高度的通用類別。
| Class | Styles |
|---|---|
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-lh | max-height: 1lh; |
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>] 語法,根據完全自訂的值來設定 maximum height:
<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() 函式。
在 max-height 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:
<div class="h-48 max-h-full md:max-h-screen ..."> <!-- ... --></div>在變體文件中了解更多關於使用變體的資訊。
max-h-<number> 通用類別由 --spacing 主題變數驅動,可以在你自己的主題中自訂:
@theme { --spacing: 1px; }在主題變數文件中了解更多關於自訂間距比例的資訊。