All Cheat Sheets

CSS Flexbox & Grid

Complete CSS Flexbox and Grid layout reference — containers, items, alignment, and common patterns.

Flexbox Container

Enable flexdisplay: flex
Directionflex-direction: row | column
Wrapflex-wrap: wrap
Justifyjustify-content: center | space-between | space-around
Align itemsalign-items: center | stretch | flex-start
Gapgap: 1rem

Flexbox Items

Growflex-grow: 1
Shrinkflex-shrink: 0
Basisflex-basis: 200px
Shorthandflex: 1 0 auto
Self alignalign-self: flex-end
Orderorder: -1

Grid Container

Enable griddisplay: grid
Columnsgrid-template-columns: repeat(3, 1fr)
Rowsgrid-template-rows: auto 1fr auto
Gapgap: 1rem 2rem
Auto-fitgrid-template-columns: repeat(auto-fit, minmax(250px, 1fr))
Areasgrid-template-areas: 'header header' 'nav main'

Grid Items

Column spangrid-column: span 2
Row spangrid-row: 1 / 3
Areagrid-area: header
Self placeplace-self: center

Alignment (Both)

Center allplace-items: center
Place contentplace-content: center
Justify selfjustify-self: end
Align contentalign-content: space-between

Free tools for this

Keep the references coming

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.