P2.6: CSS Grid Layouts

CSS Grid is the most powerful 2-dimensional layout engine in web design, allowing layouts to align across rows and columns simultaneously.


1. Grid Column and Row Templates

Define grids with columns and rows:

  • grid-template-columns: Defines vertical tracks (uses fr fractional unit).
  • grid-gap / gap: Defines grid spacing.
  • grid-template-areas: Maps layout templates directly using semantic strings.
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}
Jen Simmons

Jen SimmonsView Profile πŸ”—

Real-World Developer Case Study
18 Years Exp
RoleCSS Grid Evangelist & Designer
Salaryβ‚Ή82 Lakhs/yr equivalent
CompanyApple / WebKit
Core Tech Stack
CSS GridWeb Design SystemsSafari WebKit Dev

β€œCSS Grid allows us to build layouts that were impossible before. We can place items overlapping, auto-size grids dynamically without media queries, and design page wireframes easily.”


πŸŽ“ Practice Assignment Tasks

  • Create a 3-column photo gallery grid using CSS Grid.
  • Make it responsive using `repeat(auto-fit, minmax(200px, 1fr))`.
Stuck? Hints available
/* Write your CSS styling rules here to complete the assignment */
πŸ”’ Code requirements not met yet. Complete the tasks above.
πŸ”’ Complete the Practice Assignment above to unlock completion.
Advertisement
NS
Ask Nextsem
AI Mode
NS
Home
Course
Playground