--- id: 587d7fa5367417b2b2512bbd title: Extend One Set of CSS Styles to Another Element challengeType: 0 videoUrl: '' localeTitle: 将一组CSS样式扩展到另一个元素 --- ## Description
Sass有一个名为extend的功能,可以很容易地从一个元素中借用CSS规则并在另一个元素上构建它们。例如,下面的CSS规则块会设置一个.panel类。它有background-colorheightborder
。面板{
背景颜色:红色;
身高:70px;
边框:2px纯绿色;
}
现在你想要另一个名为.big-panel 。它具有与.panel相同的基本属性,但也需要widthfont-size 。可以从.panel复制并粘贴初始CSS规则,但是当您添加更多类型的面板时,代码会变得重复。 extend指令是一种重用为一个元素编写的规则的简单方法,然后为另一个元素添加更多:
。大面板{
@extend .panel;
宽度:150px;
font-size:2em;
}
除了新样式之外, .big-panel还具有与.panel相同的属性。
## Instructions
创建一个扩展.info的类.info-important ,并将background-color设置为洋红色。
## Tests
```yml tests: - text: 您的info-important类应该将background-color设置为magenta 。 testString: 'assert(code.match(/\.info-important\s*?{[\s\S]*background-color\s*?:\s*?magenta\s*?;[\s\S]*}/gi), "Your info-important class should have a background-color set to magenta.");' - text: 您的info-important类应使用@extendinfo类继承样式。 testString: 'assert(code.match(/\.info-important\s*?{[\s\S]*@extend\s*?.info\s*?;[\s\S]*/gi), "Your info-important class should use @extend to inherit the styling from the info class.");' ```
## Challenge Seed
```html

Posts

This is an important post. It should extend the class ".info" and have its own CSS styles.

This is a simple post. It has basic styling and can be extended for other uses.

```
## Solution
```js // solution required ```