CSS Grid
エンジニアのためのWebチートシート
CSS Grid Layoutは、CSSの強力な2次元レイアウトシステムです。 行と列の両方を同時に制御でき、複雑なレイアウトを簡単に実現できます。 Flexboxと組み合わせることで、モダンなWebレイアウトを効率的に構築できます。
CSS Gridの基本
CSS Gridを指定しない
1
2
3
4
CSS Gridを指定する
1
2
3
4
grid-template-columns / rows
grid-template-columns
1
2
3
4
5
6
grid-template-rows
1
2
3
4
5
6
gap
gap
1
2
3
4
5
6
row-gap / column-gap
1
2
3
4
5
6
justify-items / align-items
justify-items: start
1
2
3
justify-items: center
1
2
3
justify-items: end
1
2
3
align-items: start
1
2
align-items: center
1
2
align-items: end
1
2
justify-content / align-content
justify-content: space-between
1
2
3
justify-content: space-around
1
2
3
justify-content: space-evenly
1
2
3
align-content: space-between
1
2
3
4
grid-template-areas
grid-template-areas
Header
Sidebar
Main
Aside
Footer
fr / minmax / repeat
fr
1fr
2fr
1fr
minmax()
min 60px
2fr
repeat()
1
2
3
4
auto-fit
1
2
3
子要素に指定するプロパティ
grid-column
1
2
3
4
5
grid-row
1
2
3
4
5
justify-self
start
center
end
stretch
align-self
start
center
end
stretch