liveBook · Manning

Main axis

The main axis is the primary direction in which a flex container arranges and distributes its flex items.

How 3 Manning books explain it

Web Design Playground, Second Edition

The main axis is the primary direction in which a flex container arranges its flex items.

How it is used
Guides the direction and arrangement of flex items in containers and nested page layouts.
How deep it goes
Defines the axis, shows how to select its direction, and applies it in a page layout; defers fuller two-dimensional layout to CSS Grid.
Examples
Uses direction choices and a layout with a stacked body, side-by-side header and navigation items, and article and sidebar columns.
What you can do after
Build it from scratch by choosing vertical or horizontal flex containers and arranging items along their main axes.

Read how Web Design Playground, Second Edition explains main axis →

CSS in Depth, Second Edition

The main axis is the primary direction in which a flex container lays out and distributes its flex items.

How it is used
Explains how flexbox places, sizes, spaces, and wraps items along their primary layout direction.
How deep it goes
Defines the axis, follows its rotation through flex-direction, and explains sizing, spacing, wrapping, and height constraints.
Examples
Uses navigation, tiles, a nested sidebar column, axis diagrams, and spacing and wrapping property examples.
What you can do after
Apply via CSS Flexbox to choose flow direction, predict sizing dimensions, distribute space, and diagnose constrained column layouts.

Read how CSS in Depth, Second Edition explains main axis →

Web Design Playground

The primary flexbox axis running top to bottom along which flex items are arranged when the container is vertical.

How it is used
Organizes flex items by identifying their direction of travel within a flex container.
How deep it goes
Defines the main axis against the cross axis and applies vertical direction and start alignment in page layouts.
Examples
Uses a holy-grail page layout and a photo gallery with vertically stacked body content.
What you can do after
Apply it via CSS flex-direction: column and justify-content: flex-start to stack page elements from the top.

Read how Web Design Playground explains main axis →

Also covered in

What to know first

Related concepts

Questions about main axis

What is main axis?

The main axis is the primary direction in which a flex container arranges and distributes its flex items.

Which Manning books explain main axis?

Web Design Playground, Second Edition, CSS in Depth, Second Edition and Web Design Playground.

What should I know before learning main axis?

Manning books that teach main axis usually introduce body element, flexbox, footer section and navigation first.

What is the difference between main axis and cross axis?

The main axis is the primary direction in which a flex container arranges and distributes its flex items. The layout axis perpendicular to a flex container's main axis, along which items can be aligned.

What are the parts of main axis?

Main axis includes flex item.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.