Catalog / CSS Flexbox Cheatsheet
CSS Flexbox Cheatsheet
A comprehensive cheat sheet covering CSS Flexbox properties, values, and usage examples for creating flexible and responsive layouts.
Flexbox Fundamentals
Enabling Flexbox
To use flexbox, set the |
|
|
Flex Direction
|
Items are placed side by side (horizontally) - Default value. |
|
Items are placed side by side in reverse order (right to left). |
|
Items are placed top to bottom (vertically). |
|
Items are placed bottom to top (vertically reversed). |
Flex Wrap
|
Items stay in a single line, even if they overflow the container - Default value. |
|
Items wrap to the next line when they overflow the container. |
|
Items wrap to the previous line when they overflow the container. |
Justify Content & Align Items
Justify Content
|
Items are aligned to the start of the container - Default value. |
|
Items are aligned to the end of the container. |
|
Items are centered in the container. |
|
Items are evenly distributed; first item is at the start, last item is at the end. |
|
Items are evenly distributed with equal space around each item. |
|
Items are distributed so that the spacing between any two items (neither the first nor the last) is the same. |
Align Items
|
Items are stretched to fit the container - Default value. |
|
Items are aligned to the top of the container. |
|
Items are aligned to the bottom of the container. |
|
Items are vertically centered in the container. |
|
Items are aligned based on their baselines. |
Flex Item Properties
Flex Grow
|
Item does not grow to fill available space - Default value. |
|
Item grows to fill available space. |
|
Item grows to fill n times the available space compared to other items with |
Flex Shrink
|
Item can shrink if necessary - Default value. |
|
Item does not shrink, even if it overflows. |
|
Item shrinks n times more than other items with |
Flex Basis
|
Item size is based on its content - Default value. |
|
Item size is based on |
|
Item has a fixed size (e.g., |
|
Keyword specifying an automatic size based on the element’s content. |
Flex Shorthand
The
|
|
|
|
|
|
Advanced Flexbox
Align Self
|
Item inherits the |
|
Item is aligned to the top of the container, overriding the container’s |
|
Item is aligned to the bottom of the container, overriding the container’s |
|
Item is vertically centered in the container, overriding the container’s |
|
Item is aligned based on its baseline, overriding the container’s |
|
Item is stretched to fit the container, overriding the container’s |
Order
|
Items are displayed in their source order - Default value. |
|
Items are reordered based on the numerical value of the |
Note |
Items with the same order value will be displayed in their source order. |
Align Content
|
Lines stretch to take up the remaining space - Default value. |
|
Lines are packed at the start of the container. |
|
Lines are packed at the end of the container. |
|
Lines are packed in the center of the container. |
|
Lines are evenly distributed; the first line is at the start, the last is at the end. |
|
Lines are evenly distributed with equal space around each line. |