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

CSS Grid Cheat Sheet

Grid templates, repeats, gaps and placement snippets for responsive layouts.

Grid templatesrepeat and minmaxPlacementResponsive grids

Basic grid

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

Responsive columns

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

Placement

.card {
  grid-column: 1 / 3;
  grid-row: 1 / 2;
}

Center content

.grid-center {
  display: grid;
  place-items: center;
}

Template areas

.layout {
  display: grid;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  grid-template-columns: 240px 1fr;
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
✓ Copied!