フレックスコンテナ内のアイテムの主軸方向の配置を指定するプロパティです。flex-start、flex-end、center、space-between、space-aroundなどがあり、アイテム間の余白配分を制御します。
justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly| justify-start | justify-content: flex-start |
| justify-center | justify-content: center |
| justify-between | justify-content: space-between |
| justify-end | justify-content: flex-end |
safe対応はjustify-center-safe(v4.1+)。
.element {
justify-content: flex-start;
}justify-content: center;アイテムを中央に配置
justify-content: space-between;アイテム間に均等な間隔を配置
justify-content: flex-start;アイテムを左(開始位置)に寄せて配置
justify-content: space-around;アイテムの両端と間に均等な余白を配置
centerはボタンやカードの中央配置によく使う。space-betweenはナビゲーションメニューに最適。
space-betweenは最終行で要素がまばらに広がる問題があり、AIは一覧グリッドに安易にspace-betweenを使いがちです(gap+flex-start、またはgridが正解のことが多い)。またjustify-contentは主軸方向にしか効かない点の混同も定番です。
カード一覧のspace-betweenで最終行が不自然に広がる問題を、gapベースの実装に直して
そのままAIチャットに貼り付けて使える依頼文の例です。ページ上部の「AI用にコピー」でこのページ全体をコンテキストとして渡せます。