CSS flex-direction Property
The flex-direction property in CSS defines the direction of flex items inside a flex container. It determines whether the items should be placed in a row or a column and whether they should be reversed.
1. Syntax
| Value | Description |
|---|---|
row (default) | Items are placed horizontally (left to right). |
row-reverse | Items are placed horizontally in reverse (right to left). |
column | Items are placed vertically (top to bottom). |
column-reverse | Items are placed vertically in reverse (bottom to top). |
2. Basic Example
✅ Default Flex Direction (row)
✅ Items are placed in a row (left to right).
✅ Reverse Row (row-reverse)
✅ Items start from the right and move left.
✅ Column Layout (column)
✅ Items stack vertically from top to bottom.
✅ Reverse Column (column-reverse)
✅ Items stack vertically from bottom to top.
3. Example – Different flex-direction Values
✅ The items appear side by side in a row.
4. Combining with flex-wrap (Using flex-flow)
You can also use flex-flow, which combines flex-direction and flex-wrap:
✅ Items stack in a column and wrap when needed.
5. Best Practices
✔ Use row for horizontal layouts.
✔ Use column for vertical layouts.
✔ Combine with justify-content and align-items for better alignment.

