liveBook · Manning

Flex base size

As explained in Math for Web Design

A flex base size is the initial main-axis size assigned to a flex item before Flexbox distributes free space by growing or shrinking items.

The flex base size is a flex item’s starting main-axis size, before Flexbox distributes free space by growing or shrinking items. In a row container it means width; in a column container it means height. section 5.1

The browser determines the base size in this order:

  • Use a specific flex-basis value directly, including a length, percentage, content, max-content, min-content, or fit-content. section 5.1.1
  • When flex-basis is auto, use the item’s width on a horizontal main axis if width is declared. section 5.1.1
  • When flex-basis is auto and width is absent, measure the item’s intrinsic content size. section 5.1.1

Why flex-basis overrides width

With flex-basis: 100px and width: 200px, the item starts at 100px because the explicit flex-basis value overrides width. The browser then totals the items’ base sizes, compares that total with the container, and decides whether growing or shrinking is required. section 5.1.1

How Math for Web Design covers it

How deep it goes
Defines the selection algorithm and connects base-size totals to growth or shrinkage, but defers distribution formulas.
Examples
Uses explicit 250px and 100px bases, auto with width, auto with intrinsic content, and a 600px three-item container.
What you can do after
Diagnose unexpected flex-item sizes by tracing flex-basis, width, intrinsic content size, and the container’s available space.
How it connects
Connects flex-basis with width, intrinsic sizing, flex-grow, flex-shrink, flex shorthand, and min-width or max-width constraints.

Related concepts

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