CSS justify-contentプロパティ
例
フレックスボックスの <div> 要素内の各項目の周囲に空白を残します:
div
{
display: flex;
justify-content: space-around;
}
試してみる »
ブラウザサポート
表内の数字は、このプロパティをサポートする最初のブラウザのバージョン番号を示します。
-webkit-、-ms-、または -moz- の直後の数字は、その接頭辞付きプロパティをサポートする最初のバージョンです。
| プロパティ | |||||
|---|---|---|---|---|---|
| justify-content | 29.0 21.0 -webkit- |
11.0 | 28.0 18.0 -moz- |
9.0 6.1 -webkit- |
17.0 |
定義と使い方
justify-content は、フレックスボックス要素の主軸(横軸)方向の整列方法を設定または取得するために使用します。
ヒント:align-content プロパティを使用して、交差軸(垂直)上の各項目を整列します。
| デフォルト値: | flex-start |
|---|---|
| 継承: | 否 |
| アニメーション化可能: | いいえ。参照:アニメーション化可能(animatable)。 |
| バージョン: | CSS3 |
| JavaScript 構文: | object.style.justifyContent="space-between" 試してみる |
/* 整列方式 */
justify-content: center; /* 中央寄せ */
justify-content: start; /* 行頭から配置 */
justify-content: end; /* 行末から配置 */
justify-content: flex-start; /* 行頭の開始位置から配置 */
justify-content: flex-end; /* 行末位置から配置 */
justify-content: left; /* 整列コンテナの左端に一列に詰めて配置 */
justify-content: right; /* 要素はコンテナの右端を基準に一列に詰めて整列 */
/* ベースライン整列 */
justify-content: baseline;
justify-content: first baseline;
justify-content: last baseline;
/* フレックス要素の分配方法 */
justify-content: space-between; /* 各要素を均等に配置
最初の要素は始点に、最後の要素は終点に配置 */
justify-content: space-around; /* 各要素を均等に配置
各要素の周囲に同じスペースを割り当てます */
justify-content: space-evenly; /* 各要素を均等に配置
各要素の間隔は等間隔です */
justify-content: stretch; /* 各要素を均等に配置
'auto' サイズの要素はコンテナのサイズに合わせて引き伸ばされます */
/* オーバーフロー整列 */
justify-content: safe center;
justify-content: unsafe center;
/* グローバル値 */
justify-content: inherit;
justify-content: initial;
justify-content: unset;
justify-content: center; /* 中央寄せ */
justify-content: start; /* 行頭から配置 */
justify-content: end; /* 行末から配置 */
justify-content: flex-start; /* 行頭の開始位置から配置 */
justify-content: flex-end; /* 行末位置から配置 */
justify-content: left; /* 整列コンテナの左端に一列に詰めて配置 */
justify-content: right; /* 要素はコンテナの右端を基準に一列に詰めて整列 */
/* ベースライン整列 */
justify-content: baseline;
justify-content: first baseline;
justify-content: last baseline;
/* フレックス要素の分配方法 */
justify-content: space-between; /* 各要素を均等に配置
最初の要素は始点に、最後の要素は終点に配置 */
justify-content: space-around; /* 各要素を均等に配置
各要素の周囲に同じスペースを割り当てます */
justify-content: space-evenly; /* 各要素を均等に配置
各要素の間隔は等間隔です */
justify-content: stretch; /* 各要素を均等に配置
'auto' サイズの要素はコンテナのサイズに合わせて引き伸ばされます */
/* オーバーフロー整列 */
justify-content: safe center;
justify-content: unsafe center;
/* グローバル値 */
justify-content: inherit;
justify-content: initial;
justify-content: unset;
CSS 構文
justify-content: flex-start|flex-end|center|space-between|space-around|initial|inherit;
プロパティ値
| 值 | 説明 | テスト |
|---|---|---|
| flex-start | デフォルト値。行頭の開始位置から配置します。 | |
| flex-end | 行末位置から配置します。 | |
| center | 中央に配置します。 | |
| space-between | 各要素を均等に配置し、最初の要素は始点に、最後の要素は終点に配置します。 | |
| space-evenly | 各要素を均等に配置し、各要素の間隔は等間隔です。 | |
| space-around | 各要素を均等に配置し、各要素の周囲に同じスペースを割り当てます。 | |
| initial | このプロパティをデフォルト値に設定します。参照:initial。 | |
| inherit | このプロパティを親要素から継承します。参照:inherit。 |
関連記事
CSS リファレンス:align-content プロパティ
CSS リファレンス:align-items プロパティ
CSS リファレンス:align-self プロパティ
その他の拡張
CSS リファレンス