2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: 5a858944d96184f06fd60d61
|
|
|
|
|
challengeType: 0
|
2020-02-11 21:39:15 +08:00
|
|
|
|
videoUrl: 'https://scrimba.com/p/pByETK/cqwREC4'
|
|
|
|
|
forumTopicId: 301129
|
|
|
|
|
localeTitle: 创建你的第一个 CSS 网格
|
2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-02-11 21:39:15 +08:00
|
|
|
|
<section id='description'>
|
|
|
|
|
通过将属性<code>display</code>的值设为<code>grid</code>,使 HTML 元素变为网格容器。通过前面的操作,你可以对该容器使用与 CSS 网格(CSS Grid)相关的属性。
|
|
|
|
|
<strong>注意:</strong><br>在 CSS 网格中,父元素称为<dfn>容器(container)</dfn>,它的子元素称为<dfn>项(items)</dfn>。
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Instructions
|
2020-02-11 21:39:15 +08:00
|
|
|
|
<section id='instructions'>
|
|
|
|
|
将类为<code>container</code>的 div 的<code>display</code>属性改为<code>grid</code>。
|
|
|
|
|
</section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
2020-02-11 21:39:15 +08:00
|
|
|
|
- text: '<code>container</code>类应该有<code>display</code>属性且值为<code>grid</code>。'
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert(code.match(/.container\s*?{[\s\S]*display\s*?:\s*?grid\s*?;[\s\S]*}/gi));
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='html-seed'>
|
|
|
|
|
|
|
|
|
|
```html
|
|
|
|
|
<style>
|
|
|
|
|
.d1{background:LightSkyBlue;}
|
|
|
|
|
.d2{background:LightSalmon;}
|
|
|
|
|
.d3{background:PaleTurquoise;}
|
|
|
|
|
.d4{background:LightPink;}
|
|
|
|
|
.d5{background:PaleGreen;}
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
|
.container {
|
|
|
|
|
font-size: 40px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
background: LightGray;
|
2020-02-11 21:39:15 +08:00
|
|
|
|
/* 请在本行以下添加你的代码 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 请在本行以上添加你的代码 */
|
2018-10-10 18:03:03 -04:00
|
|
|
|
}
|
|
|
|
|
</style>
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
|
<div class="container">
|
|
|
|
|
<div class="d1">1</div>
|
|
|
|
|
<div class="d2">2</div>
|
|
|
|
|
<div class="d3">3</div>
|
|
|
|
|
<div class="d4">4</div>
|
|
|
|
|
<div class="d5">5</div>
|
|
|
|
|
</div>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|
2018-10-10 18:03:03 -04:00
|
|
|
|
</section>
|
2020-02-11 21:39:15 +08:00
|
|
|
|
|