A two dimensional layout system, controlling layout in rows and columns.
The container that holds the entire CSS grid. It is the element that has the display: grid or display: inline-grid property on it.
.grid-container {
display: grid;
}
Any element that is a direct child of a grid container.
.grid-container {
display: grid;
}
Grid Item 1
Grid Item 2
Grid Item 3
The vertical and horizontal lines that divide the grid and separate the columns and rows.
A single unit of a CSS grid.
Rectangular space surrounded by four grid lines.
A grid area can contain any number of grid cells.
The space between two grid lines.
This space can be horizontal or vertical.
A horizontal track of a grid.
A vertical track of a grid.
The space between rows and columns in a grid.
.grid-container {
display: grid;
grid-template-columns:
repeat(3, 1fr);
}
Grid Item 1
Grid Item 2
Grid Item 3
A way to define the number of rows and columns as well as their size.
.grid-container {
display: grid;
grid-template-columns: 1fr 2fr 1fr;
grid-template-rows: 4fr 1fr 2fr;
}
with dynamic row and column size
.grid-container {
display: grid;
grid-template-columns: minmax(auto, 40%) 1fr 12rem;
grid-template-rows: minmax(75px, auto) minmax(75px, 150px) auto;
}
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
.grid-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
}
Grid items are positioned using grid lines.
.item-1 {
grid-row: 2/3;
grid-column: 2/3;
}
.item-3 {
grid-row: 3/4;
grid-column: 3/4;
}
Item 1
Item 2
Item 3
What is grid-area again?
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: repeat(4, 1fr);
grid-template-areas:
"header header header"
"sidebar content-1 content-1"
"sidebar content-2 content-3"
"footer footer footer";
}
header
sidebar
Content-1
Content-2
Content-3
footer
Go to the code sandbox and fill up the available space with the person tiles. Think of mobile, tablet and desktop widths. Align the previously built person tiles using a CSS grid layout.
Hint: Try if you can make the layout responsive without media queries.