尺寸設定
用於設定元素最大高度的實用工具。
類別 | 樣式 |
---|---|
max-h-<number> | max-height: calc(var(--spacing) * <number>); |
max-h-<fraction> | max-height: calc(<fraction> * 100%); |
max-h-auto | max-height: auto; |
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-24
和 max-h-64
的 max-h-<number>
實用類別,根據間距比例將元素設定為固定的最大高度
<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-1/2
和 max-h-2/5
的 max-h-<fraction>
實用類別,為元素提供基於百分比的最大高度
<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()
函式。
前綴一個 max-height
實用類別 使用類似 md:
的斷點變體,以便僅在中等 螢幕尺寸及以上套用該實用類別
<div class="h-48 max-h-full md:max-h-screen ..."> <!-- ... --></div>
請參閱變體文件,以瞭解有關使用變體的更多資訊。
-<number>
max-h-<number>
實用類別由 --spacing
主題變數驅動,可以在您自己的主題中自訂
@theme { --spacing: 1px; }
請參閱主題變數文件,深入了解如何自訂間距比例。