Flexbox Examples
These examples are to accompany the Flexbox articles on MDN.
Basic concepts of flexbox
- The flex container
- The flex-direction property
- Multi-line flex containers
- The flex-flow shorthand
- The flex properties
- Flex shorthands
- Align items
- Justify content
Relationship to other layout methods
- Writing Modes
- Floated layout
- Simple flex layout
- Simple grid layout
- Demo of display: contents
Alignment
- Centering a box
- Alignment on the cross axis with align-items
- Aligning individual items with align-self
- Changing the main axis to column and aligning items
- Aligning content on the cross axis
- Changing the main axis to column
- Main axis alignment with justify-content
- Main axis alignment with flex-direction column
- Main axis alignment in RTL writing mode
- Main axis alignment with reversed row
- Alignment with auto margins
Order
- The flex-direction property
- The order property
- Using negative values for order
- A usecase for the order property
Ratios on the main axis
- Concepts of min and max-content
- The flex-basis property
- The flex-grow property
- Ratios and the flex-grow property
- The flex-shrink property
- min-content sizing and the flex-shrink property
- Ratios and the flex-shrink property
Mastering wrapping of flex items
- Wrapping when flex-direction is row
- Wrapping when flex-direction is column
- Wrapping when flex-direction is row-reverse
- Grid and two-dimensions
- A flexbox grid
- Gaps between flex items
- Setting an item to visibility: collapse
- Wrapped items with visibility: collapse
Common Use Cases of Flexbox
- Navigation
- Navigation distributing space to items
- Split navigation
- Centering an item
- Card layout
- Media object
- Flipped media object
- Input element and button
- Adding a label to the input and button
Backwards compatibility of flexbox
- With floats as a fallback
- With inline-block as a fallback
- With table-cell as a fallback
- With the vertical-align property as a fallback for alignment