πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

Grid Layout Patterns

Web Styles🟒 Free Lesson

Advertisement

Grid Layout Patterns

Holy grail, dashboard, gallery, and responsive grid patterns.

Overview

Common CSS Grid layout patterns for web applications.

Key Concepts

  • Holy Grail β€” Classic header-sidebar-content-footer
  • Dashboard β€” Complex grid with widgets
  • Gallery β€” Image grid with varying sizes
  • Pancake Stack β€” Vertical stacking sections
  • Sidebar Layout β€” Content with sidebar

Code Examples

/* Holy grail layout */
.holy-grail {
  display: grid;
  grid-template-areas:
    "header header header"
    "nav main aside"
    "footer footer footer";
  grid-template-columns: 200px 1fr 200px;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.header { grid-area: header; }
.nav { grid-area: nav; }
.main { grid-area: main; }
.aside { grid-area: aside; }
.footer { grid-area: footer; }

/* Dashboard */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(100px, auto);
  gap: 1rem;
}

.widget-wide { grid-column: span 2; }
.widget-tall { grid-row: span 2; }

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
}

.gallery-item.featured {
  grid-column: span 2;
  grid-row: span 2;
}

/* Pancake stack */
.pancake-stack {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* Sidebar layout */
.with-sidebar {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* Responsive sidebar */
.responsive-sidebar {
  display: grid;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .responsive-sidebar {
    grid-template-columns: 250px 1fr;
  }
}

/* Auto-fit cards */
.auto-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

/* Masonry-like */
.masonry {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 10px;
  gap: 1rem;
}

.masonry-item:nth-child(1) { grid-row-end: span 12; }
.masonry-item:nth-child(2) { grid-row-end: span 8; }
.masonry-item:nth-child(3) { grid-row-end: span 15; }

Practice

Build a responsive dashboard with multiple grid patterns.

⭐

Premium Content

Grid Layout Patterns

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert Web Development Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement