max-height
試してみましょう
max-height
は height
を上書きしますが、 min-height
は max-height
を上書きします。
構文
css
/* <length> 値 */
max-height: 3.5em;
/* <percentage> 値 */
max-height: 75%;
/* キーワード値 */
max-height: none;
max-height: max-content;
max-height: min-content;
max-height: fit-content(20em);
/* グローバル値 */
max-height: inherit;
max-height: initial;
max-height: revert;
max-height: unset;
値
<length>
-
max-height
を絶対的な値で定義します。 <percentage>
-
max-height
を包含ブロックの高さに対するパーセント値で定義します。 none
-
ボックスの寸法を制限しません。
max-content
-
内容物が推奨する
max-height
です。 min-content
-
内容物の最小の
max-height
です。 fit-content(
<length-percentage>
)-
利用可能な空白を指定された引数で置き換えた
fit-content
式を使用します。すなわち、min(max-content, max(min-content, 引数))
です。
アクセシビリティの考慮
テキストを大きくするためにページを拡大したときに、 max-height
を設定した要素が切り取られたり、他のコンテンツを覆い隠したりしないことを確認してください。
公式定義
形式文法
max-height =
none |
<length-percentage [0,∞]> |
min-content |
max-content |
fit-content( <length-percentage [0,∞]> )
<length-percentage> =
<length> |
<percentage>
例
パーセント値とキーワード値を用いた max-height の設定
css
table {
max-height: 75%;
}
form {
max-height: none;
}
仕様書
Specification |
---|
CSS Box Sizing Module Level 4 # width-height-keywords |
CSS Box Sizing Module Level 4 # sizing-values |
ブラウザーの互換性
BCD tables only load in the browser
関連情報
- ボックスモデル、
box-sizing
height
,min-height
- 対応する論理プロパティ:
max-inline-size
,max-block-size