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. The main axis is where items run; the cross axis is the direction across them, like the height of a horizontal row or the width of a vertical column. section 12.2

Find the cross axis in two small steps:

  • Set the main direction with flex-direction. A row runs horizontally, so its cross axis runs vertically. section 12.2
  • A column runs vertically, so its cross axis runs horizontally. section 12.2
  • Use align-items to choose how flex items line up across that cross axis. section 12.2
container {
    display: flex;
    align-items: stretch|flex-start|flex-end|center|baseline;
}

This rule offers cross-axis alignment choices such as stretching, starting, ending, centering, or lining up baselines. section 12.2

A row of items

With flex-direction: row, items travel left to right on the main axis. Centering them with align-items: center moves them across the vertical cross axis. section 12.2

How Web Design Playground covers it

How deep it goes
Defines the perpendicular axis and connects it to flex-direction and alignment choices.
Examples
Uses header and div flex containers plus row and column direction rules.
What it assumes
Starts by defining main and cross axes before asking readers to choose container directions.
What you can do after
Operate/configure it by selecting cross-axis alignment with align-items in a flex container.
How it connects
Connects flex containers with flex-direction, 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.