Hackforge Academy

Category: javascript

css grid rows columns responsive layouts

Published on 30 Sep 2026

Explanation

CSS Grid is a two-dimensional layout system that works with both rows and columns.

Code:

.container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

Explanation

grid-template-columns defines the number and size of columns in a grid.

Code:

.container {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
}

Explanation

grid-template-rows defines the height of grid rows.

Code:

.container {
  display: grid;
  grid-template-rows: 100px 200px;
}

Explanation

Grid items can span multiple columns or rows using grid-column and grid-row.

Code:

.item {
  grid-column: span 2;
}

.header {
  grid-column: 1 / -1;
}

Explanation

CSS Grid can create responsive layouts using repeat(), minmax(), and auto-fit.

Code:

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

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community