CSS Grid is a powerful tool for creating two-dimensional layouts on the web.
Grid container holds grid items and defines the grid structure.
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 10px;
}
Define named areas for easier placement:
grid-template-areas:
"header header header"
"sidebar main main"
"footer footer footer";
Use media queries to adjust grid for different screen sizes.
@media (max-width: 768px) {
.grid {
grid-template-columns: 1fr;
}
}
Grid makes complex layouts simple and maintainable.