The concepts of
Flexbox
Flex container setup
Create a flex container
With display: flex or display: inline-flex.
Identify flex items
Child boxes escape Flexbox with position: absolute, text runs get wrapped in an anonymous box.
Set main direction
With flex-direction.
Allow flex items to wrap
With flex-wrap.
Calculate available space for flex items
Flex items are laid out into the flex container’s content box. Its size depends on how the flex container itself is laid out.
Insert gaps between flex items and flex lines
With gap.
Stretch flex lines
With align-items. A flex item will listen to this suggestion if it has align-self: auto.
Suggest stretching to flex items
With align-items. A flex item will listen to this suggestion if it has align-self: auto.
Align flex items in the main direction
With justify-content.
Align and distribute flex lines
With align-content.
Sizing
Set the flexibility of flex items in the main direction
With flex-shrink and flex-grow. You can set this separately on each flex item.
Order flex items
With order. Lower numbers come first. Box tree order is used when two flex items have the same number.
Ask for a flex base size
Each flex item says how big it wants to be with flex-basis before it shrinks or grows.
Collect flex items into flex lines
Using the order and flex base size of each flex item.
Resolve flexible flex item sizes
Shrink or grow the flex items depending on the remaining space.
Get the hypothetical size of flex items
How big would each flex item be before any stretching happened?
Get the hypothetical size of flex lines
How big does a flex line need to be to fit its flex items, before any stretching happens?
Stretch flex lines to fill the flex container
If you set align-content to normal or stretch on the flex container.
Stretch flex items to fill their flex line
With align-self: stretch, or by listening to the flex container’s align-items suggestion.
Alignment
Remaining flex line space in the main direction
Auto margins in the main direction
Align and distribute flex items in the main direction
Remaining flex line space in the cross direction
Auto margins in the cross direction
Flex items align themselves in the cross direction
Remaining space in the flex container in the cross direction
Align and distribute flex lines in the cross direction
Advanced Concepts
Automatic minimum size of flex items
Aspect ratio transfer across axes
Shrinking flex items
Flex items will be asked to shrink if they asked for more space than is available. flex-shrink sets if they will say yes.
Growing flex items
If flex items get their flex base size and there’s room left, they’re offered to grow. flex-grow sets if they will say yes.
Percentages
Mixing writing modes
Animating flex properties
How box sizing affects flex sizing
Content-based sizing