extend的功能,可以很容易地从一个元素中借用CSS规则并在另一个元素上构建它们。例如,下面的CSS规则块会设置一个.panel类。它有background-color , height和border 。 。面板{现在你想要另一个名为
背景颜色:红色;
身高:70px;
边框:2px纯绿色;
}
.big-panel 。它具有与.panel相同的基本属性,但也需要width和font-size 。可以从.panel复制并粘贴初始CSS规则,但是当您添加更多类型的面板时,代码会变得重复。 extend指令是一种重用为一个元素编写的规则的简单方法,然后为另一个元素添加更多: 。大面板{除了新样式之外,
@extend .panel;
宽度:150px;
font-size:2em;
}
.big-panel还具有与.panel相同的属性。 .info的类.info-important ,并将background-color设置为洋红色。 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类应使用@extend从info类继承样式。
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.");'
```
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.