CSS Flexbox Guide
The Flexible Box Layout Module, makes it easier to design flexible responsive layout structure without using float or positioning.
1. Flexbox Container Properties
These properties belong strictly to the flex container (the parent element).
display
Defines a flex container.
.container {
display: flex; /* or inline-flex */
}flex-direction
Establishes the main-axis, defining the direction flex items are placed in the flex container.
row(default): left to rightrow-reverse: right to leftcolumn: top to bottomcolumn-reverse: bottom to top
justify-content
Defines the alignment along the main axis. It helps distribute extra free space.
flex-start(default): items are packed toward the start lineflex-end: items are packed toward to end linecenter: items are centered along the linespace-between: items are evenly distributed (first item is on the start line, the last on the end)space-around: items are evenly distributed with equal space around them
align-items
Defines the default behavior for how flex items are laid out along the cross axis.
stretch(default): stretch to fill the containerflex-start: items are placed at the start of the cross axisflex-end: items are placed at the end of the cross axiscenter: items are centered in the cross-axis
2. Flex Item Properties
These properties apply only to the children within the flex container.
flex-grow
Defines the ability for a flex item to grow if necessary. It accepts a unitless value that serves as a proportion. For instance, if all items have flex-grow: 1, they will share the remaining space equally.
flex-basis
Defines the default size of an element before the remaining space is distributed. It can be a length (e.g. 20%, 5rem, etc.) or a keyword.
align-self
Allows the default alignment (or the one specified by align-items) to be overridden for individual flex items.