Change the properties and watch the boxes move. The reason flexbox feels unpredictable is that justify-content and align-items are not horizontal and vertical — they are the main axis and the cross axis, and flex-direction decides which is which. Switch to column and the two swap what they control, which is why a layout that was centred one way suddenly centres the other. This tool tells you which axis is which as you change direction, rather than leaving you to work it out. align-content is left out of the output when wrapping is off, because it genuinely does nothing on a single line, and a declaration that implies an effect it cannot have is how people conclude flexbox ignored them.
| flex-direction | justify-content | align-items |
|---|---|---|
| row | Left to right | Top to bottom |
| row-reverse | Right to left | Top to bottom |
| column | Top to bottom | Left to right |
| column-reverse | Bottom to top | Left to right |
display: flex, then justify-content: center and align-items: center on the container. That centres on both axes regardless of direction, because you have centred along each one.
Because justify-content and align-items follow the axes, not the screen. In a row, justify-content works horizontally; in a column it works vertically, and align-items swaps with it. Nothing broke — the properties mean something different in the new direction.
Because it only affects how multiple lines are distributed, and with flex-wrap: nowrap there is only ever one line. Turn wrapping on and it starts working. It is omitted from the output here when wrapping is off, so the CSS does not claim an effect it cannot have.
align-items positions items within their line on the cross axis. align-content distributes the lines themselves when there are several. One is about items inside a row, the other about the rows inside the container.
Flexbox for one dimension — a row of buttons, a navigation bar, centring a thing. Grid for two — a page layout, a card grid with aligned rows and columns. The usual mistake is forcing a two-dimensional layout into flexbox and fighting it with widths and wrapping.
It spaces items without adding anything at the outer edges, so you do not need the last-child margin reset that margin-based spacing always requires. It is supported everywhere now.
The single thing that makes flexbox feel unpredictable is that justify-content and align-items do not map to horizontal and vertical — they map to the main axis and the cross axis, and flex-direction decides which is which. Set direction to column and the two properties silently swap what they control, which is why a layout that was centred horizontally suddenly centres vertically instead. The preview here states which axis is which as you change direction, rather than leaving it to be rediscovered. align-content is omitted from the output when flex-wrap is nowrap, because it has no effect at all on a single line; emitting it anyway implies a control the declaration does not have and is a common source of people believing flexbox ignored them. A zero gap is omitted for the same reason — it changes nothing and no one writes it by hand. The preview items carry flex-shrink: 0 deliberately, since letting them shrink to fit makes several justify-content values produce visually identical results and the tool would appear broken. The generated HTML is offered alongside the CSS because the class names in the CSS are meaningless without the structure they apply to.