Bookmark this page
Press Ctrl+D (Windows) or Cmd+D (Mac) to bookmark this page.
📦 Flexbox

CSS Flexbox Cheat Sheet

Flexbox essentials for direction, alignment, spacing and item sizing.

Container propertiesAlignmentItem sizingCommon patterns

Container

.container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

Wrapping

.wrap {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
}

Items

.item {
  flex: 1 1 240px;
  align-self: center;
}

Center a box

.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

Nav bars and cards

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
✓ Copied!