2018-09-30 22:01:58 +00:00
---
id: 5a90373638fddaf9a66b5d39
title: Use grid-row to Control Spacing
challengeType: 0
videoUrl: 'https://scrimba.com/p/pByETK/c9WBLU4'
2019-08-05 16:17:33 +00:00
forumTopicId: 301137
2021-01-13 02:31:00 +00:00
dashedName: use-grid-row-to-control-spacing
2018-09-30 22:01:58 +00:00
---
2020-11-27 18:02:05 +00:00
# --description--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
Of course, you can make items consume multiple rows just like you can with columns. You define the horizontal lines you want an item to start and stop at using the `grid-row` property on a grid item.
# --instructions--
Make the element with the `item5` class consume the last two rows.
# --hints--
`item5` class should have a `grid-row` property.
```js
assert(
__helpers.removeWhiteSpace($('style').text()).match(/\.item5{.*grid-row:.*}/g)
);
2018-09-30 22:01:58 +00:00
```
2020-11-27 18:02:05 +00:00
`item5` class should have a `grid-row` property which results in it consuming the last two rows of the grid.
```js
const rowStart = getComputedStyle($('.item5')[0]).gridRowStart;
const rowEnd = getComputedStyle($('.item5')[0]).gridRowEnd;
const result = rowStart.toString() + rowEnd.toString();
const correctResults = [
'24',
'2-1',
'2span 2',
'2span2',
'span 2-1',
'-12',
'span 2span 2',
'span 2auto',
'autospan 2'
];
assert(correctResults.includes(result));
```
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
# --seed--
2018-09-30 22:01:58 +00:00
2020-11-27 18:02:05 +00:00
## --seed-contents--
2018-09-30 22:01:58 +00:00
```html
< style >
.item1{background:LightSkyBlue;}
.item2{background:LightSalmon;}
.item3{background:PaleTurquoise;}
.item4{background:LightPink;}
2018-10-08 00:01:53 +00:00
2018-09-30 22:01:58 +00:00
.item5 {
background: PaleGreen;
grid-column: 2 / 4;
2020-02-27 15:20:46 +00:00
/* Only change code below this line */
2018-10-08 00:01:53 +00:00
2020-02-27 15:20:46 +00:00
/* Only change code above this line */
2018-09-30 22:01:58 +00:00
}
2018-10-08 00:01:53 +00:00
2018-09-30 22:01:58 +00:00
.container {
font-size: 40px;
min-height: 300px;
width: 100%;
background: LightGray;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 10px;
}
< / style >
2018-10-08 00:01:53 +00:00
2018-09-30 22:01:58 +00:00
< div class = "container" >
< div class = "item1" > 1< / div >
< div class = "item2" > 2< / div >
< div class = "item3" > 3< / div >
< div class = "item4" > 4< / div >
< div class = "item5" > 5< / div >
< / div >
```
2020-11-27 18:02:05 +00:00
# --solutions--
2018-09-30 22:01:58 +00:00
2019-12-01 04:32:24 +00:00
```html
< style >
.item1{background:LightSkyBlue;}
.item2{background:LightSalmon;}
.item3{background:PaleTurquoise;}
.item4{background:LightPink;}
.item5 {
background: PaleGreen;
grid-column: 2 / 4;
grid-row: 2 / 4;
}
.container {
font-size: 40px;
min-height: 300px;
width: 100%;
background: LightGray;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr;
grid-gap: 10px;
}
< / style >
< div class = "container" >
< div class = "item1" > 1< / div >
< div class = "item2" > 2< / div >
< div class = "item3" > 3< / div >
< div class = "item4" > 4< / div >
< div class = "item5" > 5< / div >
< / div >
2018-09-30 22:01:58 +00:00
```