CSS flex-flow
Property
The flex-flow
property in CSS is a shorthand for setting both flex-direction
and flex-wrap
in a single declaration. It controls the direction and wrapping behavior of flex items inside a flex container.
1. Syntax
Property | Description |
---|---|
flex-direction | Defines the main axis direction (row , row-reverse , column , column-reverse ). |
flex-wrap | Controls whether items wrap (nowrap , wrap , wrap-reverse ). |
2. Basic Usage
✅ Default Flex Behavior (row nowrap
)
✅ Items are placed in a row and do not wrap.
✅ Wrapping Items in a Column
✅ Items stack in a column and wrap when needed.
3. Example – Two-Row Wrapping Layout
✅ Items arrange in a row and wrap to a new line when needed.
4. Available Values
flex-flow Value | Equivalent to |
---|---|
row nowrap (default) | flex-direction: row; flex-wrap: nowrap; |
column wrap | flex-direction: column; flex-wrap: wrap; |
row wrap-reverse | flex-direction: row; flex-wrap: wrap-reverse; |
5. Best Practices
✔ Use flex-flow: row wrap;
for responsive layouts.
✔ Use flex-flow: column nowrap;
for vertical layouts without wrapping.
✔ Combine with justify-content
and align-items
for better alignment.