A Complete Guide To Flexbox CSS-Tricks - CSS-Tricks
A Complete Guide To Flexbox CSS-Tricks - CSS-Tricks
▾ Flexbox properties
(#aa-properties-for-the-parentflex- (#aa-properties-for-the-childrenflex-
container) Properties for the Parent items) Properties for the Children
(flex container) (flex items)
CSS
.container {
display: flex; /* or inline-flex */
}
CSS
.item {
order: 5; /* default is 0 */
}
CSS
.container {
flex-direction: row | row-reverse | column | column-reverse
}
CSS
.item {
flex-grow: 4; /* default 0 */
}
.container { This defines the ability for a flex item to shrink if necessary.
flex-wrap: nowrap | wrap | wrap-reverse;
} CSS
.item {
flex-shrink: 3; /* default 1 */
• nowrap (default): all flex items will be on one line }
• wrap: flex items will wrap onto multiple lines, from top
to bottom. Negative numbers are invalid.
• wrap-reverse: flex items will wrap onto multiple lines
from bottom to top.
wrap properties, which together define the flex container’s content” – this keyword isn’t well supported yet, so it’s
main and cross axes. The default value is row nowrap. hard to test and harder to know what its brethren max-
content, min-content, and fit-content do.
CSS
.container {
CSS
(#aa-flex) flex
This is the shorthand for flex-grow, flex-shrink and
flex-basis combined. The second and third parameters
(flex-shrink and flex-basis) are optional. The default
is 0 1 auto, but if you set it with a single number value,
like flex: 5;, that changes the flex-basis to 0%, so it’s
like setting flex-grow: 5; flex-shrink: 1; flex-
basis: 0%;.
CSS
.item {
flex: none | [ <'flex-grow'> <'flex-shrink'>? || <
}
CSS
.container {
justify-content: flex-start | flex-end | center | space-betwe
}
(#aa-align-items) align-items
This defines the default behavior for how flex items are laid
out along the cross axis on the current line. Think of it as
the justify-content version for the cross-axis
(perpendicular to the main-axis).
CSS
.container {
align-items: stretch | flex-start | flex-end | center | basel
}
(#aa-align-content) align-content
CSS
.container {
align-content: flex-start | flex-end | center | space-between
}
CSS
.container {
display: flex;
...
gap: 10px;
gap: 10px 20px; /* row-gap column gap */
row-gap: 10px;
column-gap: 20px;
}