- Read A Visual Guide to CSS3 Flexbox Properties
- Try to solve all levels in Flexbox Froggy
- If you get stuck try Chris Coiyer's A complete guide to Flexbox
display: flex;
defines a flex container. This enables a flex context for all its direct children (.flex-container > .flex-child
).
.flex-container {
display: flex; /* inline-flex */
}
The flex-direction CSS property specifies how flex items are placed in the flex container defining the main axis and the direction (normal or reversed).
flex-direction: row;
flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;
The flex container's main-axis is defined to be the same as the text direction. The main-start and main-end points are the same as the content direction.
Behaves the same as row but the main-start and main-end points are permuted.
The flex container's main-axis is the same as the block-axis. The main-start and main-end points are the same as the before and after points of the writing-mode.
Behaves the same as column but the main-start and main-end are permuted.
The flex items are packed starting from the main-start. Margins of the first flex item is flushed with the main-start edge of the line and each following flex item is flushed with the preceding.
The flex items are packed starting from the main-end. The margin edge of the last flex item is flushed with the main-end edge of the line and each preceding flex item is flushed with the following.
The flex items are packed toward the center of the line. The flex items are flushed with each other and aligned in the center of the line. Space between the main-start edge of the line and first item and between main-end and the last item of the line is the same.
Flex items are evenly distributed along the line. The spacing is done such as the space between two adjacent items is the same. Main-start edge and main-end edge are flushed with respectively first and last flex item edges.
Flex items are evenly distributed so that the space between two adjacent items is the same. The empty space before the first and after the last items equals half of the space between two adjacent items.
The cross-start margin edge of the flex item is flushed with the cross-start edge of the line.
The cross-end margin edge of the flex item is flushed with the cross-end edge of the line.
The flex item's margin box is centered within the line on the cross-axis. If the cross-size of the item is larger than the flex container, it will overflow equally in both directions.
All flex items are aligned such that their baselines align. The item with the largest distance between its cross-start margin edge and its baseline is flushed with the cross-start edge of the line.
Flex items are stretched such as the cross-size of the item's margin box is the same as the line while respecting width and height constraints.
- align-items: inherit;
- align-items: initial;
- align-items: unset;