← Cheat Sheets

CSS Flexbox Alignment Guide

Which property controls which axis.

# CSS Flexbox Alignment Guide

Which property controls which axis.

| Property | Axis | Common values |
|---|---|---|
| `flex-direction` | sets main axis | `row` `column` `row-reverse` |
| `justify-content` | main axis | `flex-start` `center` `space-between` `space-around` `space-evenly` |
| `align-items` | cross axis | `stretch` `center` `flex-start` `baseline` |
| `align-content` | cross axis, multi-line | same as justify-content |
| `flex-wrap` | wrapping | `nowrap` `wrap` |
| `gap` | spacing | `12px` |
| `flex: 1` | item grows | shorthand for grow shrink basis |
| `align-self` | one item, cross axis | `auto` `center` |
| `order` | visual order | integer |

Center anything: `display:flex; justify-content:center; align-items:center;`