Placing and sizing Grid Layout items
So far, each item we have added to a grid has taken up a single grid area. We are going to start a new example now (you can find it in the code as example_05-04
). This grid will have 20 grid items; these are just random foods and their source order within their container as a number. However, there are quite a few new things to go over in the CSS. Before we go through each new thing step by step, take a look at the code and the screenshot and see how much of it you can make sense of before reading on.
It’s also worth mentioning that I’ve purposely mixed up the use of whitespace in the values. You can write grid-row: 6 / span 2
or grid-row: 6/span 2
– either is just as valid. Just pick which you prefer.
Here’s the markup:
<div class="container">
<div class="grid-item1">1. tofu</div>
<div class="grid-item2">2. egg plant</div>
<div class="...