2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5a94fe1369fb03452672e45d
|
2020-12-16 00:37:30 -07:00
|
|
|
|
title: 使用 grid-area 属性将项目放置在网格区域中
|
2018-10-10 18:03:03 -04:00
|
|
|
|
challengeType: 0
|
2020-02-11 21:39:15 +08:00
|
|
|
|
videoUrl: 'https://scrimba.com/p/pByETK/cRrqmtV'
|
|
|
|
|
forumTopicId: 301132
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --description--
|
|
|
|
|
|
|
|
|
|
像上一个挑战那样,在为网格添加区域模板后,你可以通过引用你所定义的区域的名称,将元素放入相应的区域。为此,你需要对网格项使用`grid-area`:
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
|
|
|
|
```css
|
|
|
|
|
.item1 {
|
|
|
|
|
grid-area: header;
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
这样,类名为`item1`的网格项就被放到了`header`区域里。在这个示例中,网格项将占用整个顶行,因为这一整行都被命名为 header 区域。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --instructions--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
请使用`grid-area`属性,把类为`item5`元素放到`footer`区域。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
`item5`类应该有`grid-area`属性且值为`footer`。
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
|
assert(code.match(/.item5\s*?{[\s\S]*grid-area\s*?:\s*?footer\s*?;[\s\S]*}/gi));
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
|
# --solutions--
|
|
|
|
|
|