Interactive Lesson: CSS Grid Layout
This lesson is focused on practice.
You already learned the basic CSS Grid properties. Now you will change them directly and watch how the grid items move.
What you will practice
grid-template-columnschanges the column structure.grid-template-rowschanges explicit row heights.gapadds space between grid cells.grid-columncan make an item span across columns.- Auto-placement puts items into the next available grid cell.
Try the interactive playground
Use the controls to change the grid. Watch the preview and the CSS code update together.
CSS Grid playground
Change the grid structure and watch auto-placement fill the next available cells.
1
2
3
4
5
6
.grid-container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
background-color: #f1f5f9;
}
.grid-item:first-child,
.grid-item:last-child {
grid-column: 1 / -1;
}