liveBook · Manning

Cross axis

As explained in Web Design Playground

The axis perpendicular to the main axis in a flex container along which items can be aligned.

A flex container has two directions to think about. Items run along the main axis; the cross axis runs across it, at a right angle. Picture items in a row: their main axis is horizontal, so their cross axis is vertical. section 12.2

Find the cross axis in two steps:

  • Check flex-direction. With row, the main axis is horizontal; with column, it is vertical. section 12.2
  • Turn your attention 90 degrees. That perpendicular direction is the cross axis. section 12.2

Center items across a row

Try `.container { display: flex; flex-direction: row; align-items: center; }`. The items run along a horizontal main axis, while `align-items` centers them along the vertical cross axis. Change `row` to `column` and ask yourself: which direction is across now? section 12.2

container {
    display: flex;
    align-items: stretch|flex-start|flex-end|center|baseline;
}

Browse the available `align-items` values when choosing how flex items sit along the cross axis. section 12.2

How Web Design Playground covers it

How deep it goes
Defines the axis relative to the main axis and shows alignment choices, without descending into layout internals.
Examples
Uses a flex header, row-direction CSS, and align-items value listings.
What it assumes
Introduces Flexbox axes from their definitions and starts container setup with display: flex.
What you can do after
Operate/configure cross-axis alignment with CSS Flexbox properties.
How it connects
Connects flex-direction, the main axis, align-items, flex-wrap, and align-content.

Also explained in

Compare how 3 books explain cross axis →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground. The section links point to the parts of the book it draws on.