min-height
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
試してみましょう
min-height: 150px;
min-height: 7em;
min-height: 75%;
min-height: 10px;
This is a box where you can change the minimum height.
If there is
more content than the minimum the box will grow to the height needed by the
content.
#example-element {
display: flex;
flex-direction: column;
background-color: #5b6dcd;
justify-content: center;
color: #ffffff;
}
min-height
の値が max-height
および height
の値より大きい場合は、min-height
の値が要素の高さになります。
構文
/* 値 */
min-height: 3.5em;
min-height: anchor-size(height);
min-height: anchor-size(--myAnchor block, 200px);
/* 値 */
min-height: 10%;
/* キーワード値 */
min-height: max-content;
min-height: min-content;
min-height: fit-content;
min-height: fit-content(20em);
min-height: stretch;
/* グローバル値 */
min-height: inherit;
min-height: initial;
min-height: revert;
min-height: revert-layer;
min-height: unset;
値
-
min-height
を絶対的な値で定義します。 -
min-height
を包含ブロックの高さに対するパーセント値で定義します。 auto
-
ブラウザーが指定された要素の
min-height
を計算して選択します。 max-content
-
内容物が推奨する
min-height
です。 min-content
-
内容物の最小の
min-height
です。 fit-content
-
利用できる空間を使用しますが、 max-content を超えないようにします。すなわち、
min(max-content, max(min-content, stretch))
です。 fit-content(
)-
利用可能な空白を指定された引数で置き換えた
fit-content
式を使用します。すなわち、min(max-content, max(min-content, 引数))
です。 stretch
-
要素のマージンボックスの最小の高さを、包含ブロックの高さに制限します。マージンボックスが包含ブロック内で利用できる空間をすべて満たそうとするため、
100%
と似たような動作をしますが、結果として得られるサイズは box-sizing で決定されるボックスではなく、マージンボックスに適用されます。メモ: ブラウザーが
stretch
値のために使用する別名と実装状況については、ブラウザーの互換性の節を参照してください。
公式定義
形式文法
例
min-height の設定
table {
min-height: 75%;
}
form {
min-height: 0;
}
仕様書
Specification |
---|
CSS Box Sizing Module Level 3 # width-height-keywords |
CSS Box Sizing Module Level 4 # sizing-values |