2018-09-30 23:01:58 +01:00
---
id: 5a94fe8569fb03452672e464
title: Create Grids within Grids
challengeType: 0
2019-08-05 09:17:33 -07:00
forumTopicId: 301128
2021-01-13 03:31:00 +01:00
dashedName: create-grids-within-grids
2018-09-30 23:01:58 +01:00
---
2020-11-27 19:02:05 +01:00
# --description--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
Turning an element into a grid only affects the behavior of its direct descendants. So by turning a direct descendant into a grid, you have a grid within a grid.
For example, by setting the `display` and `grid-template-columns` properties of the element with the `item3` class, you create a grid within your grid.
# --instructions--
Turn the element with the `item3` class into a grid with two columns with a width of `auto` and `1fr` using `display` and `grid-template-columns` .
# --hints--
`item3` class should have a `grid-template-columns` property with `auto` and `1fr` as values.
```js
assert(
code.match(
/.item3\s*?{[\s\S]*grid-template-columns\s*?:\s*?auto\s*?1fr\s*?;[\s\S]*}/gi
)
);
2018-09-30 23:01:58 +01:00
```
2020-11-27 19:02:05 +01:00
`item3` class should have a `display` property with the value of `grid` .
```js
assert(code.match(/.item3\s*?{[\s\S]*display\s*?:\s*?grid\s*?;[\s\S]*}/gi));
```
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
# --seed--
2018-09-30 23:01:58 +01:00
2020-11-27 19:02:05 +01:00
## --seed-contents--
2018-09-30 23:01:58 +01:00
```html
< style >
.container {
font-size: 1.5em;
min-height: 300px;
width: 100%;
background: LightGray;
display: grid;
grid-template-columns: auto 1fr;
grid-template-rows: auto 1fr auto;
grid-gap: 10px;
grid-template-areas:
"advert header"
"advert content"
"advert footer";
}
.item1 {
background: LightSkyBlue;
grid-area: header;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.item2 {
background: LightSalmon;
grid-area: advert;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.item3 {
background: PaleTurquoise;
grid-area: content;
2020-02-27 07:20:46 -08:00
/* Only change code below this line */
2018-10-08 01:01:53 +01:00
2020-02-27 07:20:46 -08:00
/* Only change code above this line */
2018-09-30 23:01:58 +01:00
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.item4 {
background: lightpink;
grid-area: footer;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.itemOne {
background: PaleGreen;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
.itemTwo {
background: BlanchedAlmond;
}
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
< / style >
2018-10-08 01:01:53 +01:00
2018-09-30 23:01:58 +01:00
< div class = "container" >
< div class = "item1" > header< / div >
< div class = "item2" > advert< / div >
< div class = "item3" >
< div class = "itemOne" > paragraph1< / div >
< div class = "itemTwo" > paragraph2< / div >
< / div >
< div class = "item4" > footer< / div >
< / div >
```
2020-11-27 19:02:05 +01:00
# --solutions--
2018-09-30 23:01:58 +01:00
2020-07-13 18:58:50 +02:00
```html
< style > . item3 { grid-template-columns : auto 1 fr ; display : grid ; } < / style >
2018-09-30 23:01:58 +01:00
```