--- id: 5a9036ee38fddaf9a66b5d34 title: Use CSS Grid units to Change the Size of Columns and Rows challengeType: 0 videoUrl: '' localeTitle: 使用CSS网格单位更改网格列和网格行的大小 --- ## Description
您可以在CSS Grid中使用绝对性和相对性的单位(列如pxem)来定义网格行和网格列的大小。您也可以使用这些: fr :将网格列或网格行设置为可用空间的一小部分 auto :将网格列或网格行设置为其内容的宽度或高度 % :将网格列或网格行调整为对应它的容器高宽度的百分比。 这是输出下面预览的代码:
grid-template-columns:auto 50px 10%2fr 1fr;
此代码段创建了五个网格列。第一个网格列与其内容一样宽,第二个网格列是50px,第三个网格列是其容器的10%。到最后两个网格列时,剩下的空间被分为三个部分,两个部分配给第四个网格列,一个部分配配给第五个网格列。
## Instructions
创建一个包含三列的网格,其宽度如下:1fr,100px和2fr。
## Tests
```yml tests: - text: 'container类应该有一个grid-template-columns属性,该属性有三列,宽度如下: 1fr, 100px, and 2fr 。' testString: 'assert(code.match(/.container\s*?{[\s\S]*grid-template-columns\s*?:\s*?1fr\s*?100px\s*?2fr\s*?;[\s\S]*}/gi), "container class should have a grid-template-columns property that has three columns with the following widths: 1fr, 100px, and 2fr.");' ```
## Challenge Seed
```html
1
2
3
4
5
```
## Solution
```js // solution required ```