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

Advanced Grid

Web Styles🟒 Free Lesson

Advertisement

Advanced Grid

Grid areas, auto-fit, minmax, subgrid, and complex layouts.

Overview

CSS Grid enables complex, two-dimensional layouts.

Key Concepts

  • Grid Areas β€” Name grid regions
  • Auto-fit/Minmax β€” Responsive columns
  • Subgrid β€” Inherit parent grid
  • Grid Template β€” Shorthand properties
  • Implicit Grid β€” Auto-generated tracks

Code Examples

/* Named grid areas */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header header"
    "sidebar main"
    "footer footer";
  min-height: 100vh;
}

.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.footer { grid-area: footer; }

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

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* Subgrid */
.card {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 3;
}

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

.widget-1 { grid-column: 1 / 3; grid-row: 1 / 2; }
.widget-2 { grid-column: 3 / 5; grid-row: 1 / 2; }
.widget-3 { grid-column: 1 / 2; grid-row: 2 / 4; }
.widget-4 { grid-column: 2 / 4; grid-row: 2 / 3; }
.widget-5 { grid-column: 4 / 5; grid-row: 2 / 4; }
.widget-6 { grid-column: 2 / 4; grid-row: 3 / 4; }

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

.item-1 { grid-row: span 5; }
.item-2 { grid-row: span 8; }
.item-3 { grid-row: span 3; }

Practice

Build a complex dashboard layout using CSS Grid.

⭐

Premium Content

Advanced Grid

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