flex-flow
flex-flow is a shorthand for the direction flex items run in (flex-direction) and whether they wrap (flex-wrap).
Syntax
<'flex-direction'> || <'flex-wrap'>Preview
1234
Presets
Sample
Drag the bottom-right corner to resize
Shorthand breakdown
flex-flowrowflex-direction
wrapflex-wrap
Code
.box {
display: flex;
flex-flow: row wrap;
}Controls
flex-directionrow
flex-wrapwrap
1234
About
Writing the value
- Write a flex-direction value (
row,row-reverse,column,column-reverse) and a flex-wrap value (nowrap,wrap,wrap-reverse), separated by a space. - Either one alone is fine, in any order.
wrap columnmeans the same ascolumn wrap. - The one you leave out takes its initial value.
flex-flow: columniscolumn nowrap, andflex-flow: wrapisrow wrap.
The preview makes the box display: flex with a helper declaration. Each item is 30% of the box wide, so wrapping splits them into three and one.
When to use it
flex-flow: row wrap: lay out cards or tags in a row and move what does not fit to the next line.flex-flow: column: stack the items vertically.
Watch out
- As a shorthand, it resets the part you leave out to its initial value. Writing
flex-flow: columnafterflex-wrap: wrapturns wrapping back tonowrap. - In the
columndirection, items wrap only when the box has a height or a maximum height and the items do not fit. row-reverseandwrap-reversereverse only the visual order. Focus order with the Tab key and reading order stay in HTML order.- Works in all major browsers.