--- id: 5a94fe7769fb03452672e463 title: Use Media Queries to Create Responsive Layouts challengeType: 0 videoUrl: '' localeTitle: 使用媒体查询创建响应布局 --- ## Description
通过使用媒体查询重新排列网格区域,更改网格的尺寸以及重新排列项目的位置,CSS Grid可以轻松地使您的网站更具响应性。在预览中,当视口宽度为300px或更大时,列数从1变为2.广告区域然后完全占据左列。
## Instructions
当视口宽度为400px或更大时,使标题区域完全占据顶行,页脚区域完全占据底行。
## Tests
```yml tests: - text: 当视口为400px或更多时, container类应具有grid-template-areas属性,其中页脚和标题区域分别占据顶行和底行,而advert和content占据中间行的左右列。 testString: 'assert(code.match(/@media\s*?\(\s*?min-width\s*?:\s*?400px\s*?\)[\s\S]*.container\s*?{[\s\S]*grid-template-areas\s*?:\s*?"\s*?header\s*?header\s*?"\s*?"\s*?advert\s*?content\s*?"\s*?"\s*?footer\s*?footer\s*?"\s*?;[\s\S]*}/gi), "When the viewport is 400px or more, container class should have a grid-template-areas property in which the footer and header areas occupy the top and bottom rows respectively and advert and content occupy the left and right columns of the middle row.");' ```
## Challenge Seed
```html
header
advert
content
footer
```
## Solution
```js // solution required ```