How the container rules fit together
A flex container lays out its direct children along one main axis. flex-direction chooses that axis. justify-content spreads leftover space along it, align-items aligns children on the other axis, flex-wrap decides whether children may start a new line, and gap adds fixed space between them.
For example, row with justify-content: space-between, align-items: center, wrap and a 16px gap gives a navigation bar: items sit at the two ends and the middle, vertically centred, and drop to a second line on narrow screens without touching each other.
- Centering: justify-content: center plus align-items: center centres children both ways.
- Reverse directions: row-reverse and column-reverse flip the visual order without changing the HTML order, which can confuse keyboard and screen reader users.
- Gap: use gap instead of margins between children; it does not add space at the outer edges.