In this lesson, you placed two of the Coming Up cards on the events page’s grid by its line numbers, reading the numbers from DevTools’ grid overlay: the Spring Seed Swap card across the top row, and the Plant the Potatoes card two rows tall.
Key Points
- Grid lines are the edges of the tracks, and the grid overlay numbers them: across the top for the column lines, down the side for the row lines. Three columns have four column lines, one at each edge and one at each gap.
grid-columnplaces an item between two column lines: the number before the slash is the line it starts on, and the number after it is the line it ends on.grid-column: 1 / 3runs from line 1 to line 3, so it covers two columns.- Watch out: the numbers count lines, not columns.
1 / 3doesn’t mean columns one to three. To cover a three-column row, write1 / 4. - Negative numbers count back from the end, and
-1is the last line of the tracks you defined: here the columns fromgrid-template-columns.grid-column: 1 / -1covers the whole row, however many columns you define. grid-rowdoes the same with row lines. With one number, as ingrid-row: 1, the item starts on that line and covers one track.- The browser places the cards in source order and never goes back to a cell it has passed. A card with only its column lines given is placed in that order too, so when it can’t fit in the next free cell, it drops to the next row and leaves that cell empty.
- Once a card has both a row and a column, as with
grid-column: 1 / -1andgrid-row: 1, the browser gives it that spot first, then places the rest in order. - Like the
orderproperty, line numbers move a card only on screen. Tab and screen readers still follow the HTML, so the Spring Seed Swap’s link is still reached third, after the first two work days. That’s date order, which still makes sense here, so the HTML keeps its order. spancounts tracks instead of naming a line.grid-row: span 2makes an item two rows tall from wherever the browser places it, so the Plant the Potatoes card stays in date order.
Final Code
In events/upcoming.html, two cards get a second class. The Spring Seed Swap card gets featured: