Skip to content
techsnow

Layout

Flexbox Basics

Flexbox arranges items in one direction, a row or a column, and makes spacing and alignment easy. It is perfect for navbars, button groups, cards in a row and centring things.

Syntax:

.container {
  display: flex;
}

All direct children of .container now sit in a row.

Property (on container)Values
flex-directionrow (default), column, row-reverse
flex-wrapnowrap (default), wrap
gapSpace between items, e.g. 16px
.navbar {
  display: flex;
  gap: 24px;
}

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