Flexbox is the foundation of modern CSS layouts. Master these properties and you can build any 1D layout.
Container Properties
display: flex
Creates a flex container. Direct children become flex items.
flex-direction
justify-content (Main Axis)
align-items (Cross Axis)
flex-wrap
Item Properties
flex shorthand
align-self
order
Common Patterns
Gotchas
flex-basisvswidth: flex-basis wins in a flex containermin-width: autois the default for flex items — content can overflow. Usemin-width: 0to allow shrinking- Margin auto absorbs extra space:
margin-left: autopushes items to the right