min-width

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-widthCSS のプロパティで、要素の最小幅を設定します。これは width プロパティの使用値が、min-width で指定した値を下回ることを防ぎます。

試してみましょう

min-width の値が max-width および width の値より大きい場合は、min-width の値が要素の幅になります。

構文

css
/* <length> 値 */
min-width: 3.5em;
min-width: anchor-size(width);
min-width: anchor-size(--myAnchor self-inline, 200%);

/* <percentage> 値 */
min-width: 10%;

/* キーワード値 */
min-width: max-content;
min-width: min-content;
min-width: fit-content;
min-width: fit-content(20em);
min-width: stretch;

/* グローバル値 */
min-width: inherit;
min-width: initial;
min-width: revert;
min-width: revert-layer;
min-width: unset;

<length>

min-width を絶対的な値で定義します。

<percentage>

min-width を包含ブロックの幅に対するパーセント値で定義します。

auto

既定値です。指定した要素の自動値のソースは、その表示値によって異なります。ブロックボックス、インラインボックス、インラインブロック、および表レイアウトボックスすべてでは、auto0 に解決されます。

フレックスアイテムおよびグリッドアイテムの場合、最小幅の値は、 width プロパティの値などの指定された推奨サイズ、または要素にアスペクト比が設定され、高さが確定しているサイズである場合は変換されたサイズ、それ以外は最小コンテンツサイズが使用されます。フレックスアイテムまたはグリッドアイテムがスクロールコンテナーである場合、またはグリッドアイテムが複数のフレックスカラムトラックにまたがる場合、自動最小サイズは 0 になります。

max-content

内容物の推奨する min-width です。

min-content

内容物の最小の min-width です。

fit-content

利用できる空間を使用しますが、 max-content を超えないようにします。すなわち、 min(max-content, max(min-content, stretch)) です。

fit-content(<length-percentage>)

利用可能な空白を指定された引数で置き換えた fit-content 式を使用します。すなわち、 min(max-content, max(min-content, 引数)) です。

stretch

要素のマージンボックスの最小の幅を、包含ブロックの幅に制限します。マージンボックスが包含ブロック内で利用できる空間をすべて満たそうとするため、 100% と似たような動作をしますが、結果として得られるサイズは box-sizing で決定されるボックスではなく、マージンボックスに適用されます。

メモ: ブラウザーが stretch 値のために使用する別名と実装状況については、ブラウザーの互換性の節を参照してください。

公式定義

初期値auto
適用対象置換要素でないインライン要素、テーブルの行、行グループを除くすべての要素
継承なし
パーセント値包含ブロックの幅に対する相対値
計算値指定されたパーセント値または絶対的な長さ
アニメーションの種類length または パーセント値, calc();

形式文法

min-width = 
auto |
<length-percentage [0,∞]> |
min-content |
max-content |
fit-content( <length-percentage [0,∞]> ) |
<calc-size()> |
<anchor-size()>

<length-percentage> =
<length> |
<percentage>

<calc-size()> =
calc-size( <calc-size-basis> , <calc-sum> )

<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )

<calc-size-basis> =
<intrinsic-size-keyword> |
<calc-size()> |
any |
<calc-sum>

<calc-sum> =
<calc-product> [ [ '+' | '-' ] <calc-product> ]*

<anchor-name> =
<dashed-ident>

<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline

<calc-product> =
<calc-value> [ [ '*' | '/' ] <calc-value> ]*

<calc-value> =
<number> |
<dimension> |
<percentage> |
<calc-keyword> |
( <calc-sum> )

<calc-keyword> =
e |
pi |
infinity |
-infinity |
NaN

要素の最小幅を設定

css
table {
  min-width: 75%;
}

form {
  min-width: 0;
}

仕様書

Specification
CSS Box Sizing Module Level 3
# min-size-properties
CSS Box Sizing Module Level 4
# sizing-values

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
min-width
anchor-size()
Experimental
auto
fit-content
fit-content()
Experimental
max-content
min-content
stretch
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Has more compatibility info.

関連情報