Skip to content
CSS3

Flexbox Layout

Align and distribute items along one axis with flexbox.

#flexbox#layout

Code

css3
.container {
  display: flex;
  flex-direction: row;       /* row | column | row-reverse */
  justify-content: space-between;  /* main-axis alignment */
  align-items: center;       /* cross-axis alignment */
  flex-wrap: wrap;
  gap: 16px;
}

.item {
  flex: 1 1 200px;           /* grow shrink basis */
  order: 2;
  align-self: flex-end;
}

/* Center anything with three lines */
.center {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}