- 最終更新
- 2026/08/17
3秒でわかる
Flexbox や Grid で、主軸と直交する方向の揃え方を親から指定する CSS プロパティ。縦方向の中央揃えで最もよく使われます。
30秒図解
もう少し詳しく
どういうものか
align-items は、flex-direction が row のalign-items はflex-direction を column に
取る値は stretch(初期値、flex-start、flex-end、center、baseline です。
なぜ必要か
縦方向のline-height でposition を absolute にして transform でalign-items に center と
具体例
.header {
display: flex;
justify-content: space-between; /* 主軸(横)の配置 */
align-items: center; /* 交差軸(縦)の揃え */
height: 64px;
}
.card {
display: flex;
align-items: flex-start; /* 高さの違う要素を上端で揃える */
}
.card .icon {
align-self: center; /* 子ひとつだけ揃え方を変える */
}align-items: center
+------------------------------+
| [logo] [nav] | <- 縦中央に並ぶ
+------------------------------+つまずきやすいところ
justify-content とjustify-content は主軸、align-items は交差軸flex-direction を column にalign-items の center はdisplay の flex か grid がstretch なので、align-self を使う似た用語との違い
| プロパティ | 対象 | 方向 |
|---|---|---|
| justify-content | 子全体 | 主軸 |
| align-items | 子全体 | 交差軸 |
| align-content | 行同士 | 交差軸(複数行のとき) |
| align-self | 子ひとつ | 交差軸 |
覚え方
justify は

