1. サイジング
  2. max-height

サイジング

max-height

要素の最大高さを設定するためのユーティリティ。

クラススタイル
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-<number> ユーティリティ(max-h-24max-h-64 など)を使用して、要素をスペーシングスケールに基づいた固定の最大高さに設定します。

max-h-80
max-h-64
max-h-48
max-h-40
max-h-32
max-h-24
<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/2max-h-2/5 など)を使用して、要素にパーセンテージベースの最大高さを与えます。

max-h-9/10
max-h-3/4
max-h-1/2
max-h-1/4
max-h-full
<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: のようなブレークポイントバリアントを付けて、ユーティリティを適用するのはmedium 画面サイズ以上

<div class="h-48 max-h-full md:max-h-screen ...">
<!-- ... -->
</div>

バリアントの使用方法の詳細については、バリアントのドキュメントをご覧ください。

テーマのカスタマイズ

The max-h-<number> ユーティリティは、--spacing テーマ変数によって駆動され、独自のテーマでカスタマイズできます。

@theme {
--spacing: 1px;
}

スペーシングスケールのカスタマイズの詳細については、テーマ変数のドキュメントをご覧ください。

Copyright © 2025 Tailwind Labs Inc.·商標ポリシー