SyntaxStudy
Sign Up
CSS flex-direction & flex-wrap
CSS Beginner 1 min read

flex-direction & flex-wrap

flex-direction & flex-wrap

flex-direction

Controls the direction items flow:

ValueDirection
rowLeft → right (default)
row-reverseRight → left
columnTop → bottom
column-reverseBottom → top

flex-wrap

By default items try to fit on one line. flex-wrap: wrap lets them wrap to the next line when there is not enough space.

Example
.row {
  display: flex;
  flex-direction: row;     /* default */
  flex-wrap: wrap;
  gap: 12px;
}

.column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Cards that wrap to next row on small screens */
.grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.grid > * {
  flex: 1 1 200px;   /* grow, shrink, min-width */
}