Files
freeCodeCamp/curriculum/challenges/chinese/03-front-end-libraries/sass/extend-one-set-of-css-styles-to-another-element.chinese.md
Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

2.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7fa5367417b2b2512bbd Extend One Set of CSS Styles to Another Element 0 将一组CSS样式扩展到另一个元素

Description

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

Instructions

创建一个扩展.info的类.info-important ,并将background-color设置为洋红色。

Tests

tests:
  - text: 您的<code>info-important</code>类应该将<code>background-color</code>设置为<code>magenta</code> 。
    testString: assert(code.match(/\.info-important\s*?{[\s\S]*background-color\s*?:\s*?magenta\s*?;[\s\S]*}/gi));
  - text: 您的<code>info-important</code>类应使用<code>@extend</code>从<code>info</code>类继承样式。
    testString: assert(code.match(/\.info-important\s*?{[\s\S]*@extend\s*?.info\s*?;[\s\S]*/gi));

Challenge Seed

<style type='text/sass'>
  h3{
    text-align: center;
  }
  .info{
    width: 200px;
    border: 1px solid black;
    margin: 0 auto;
  }




</style>
<h3>Posts</h3>
<div class="info-important">
  <p>This is an important post. It should extend the class ".info" and have its own CSS styles.</p>
</div>

<div class="info">
  <p>This is a simple post. It has basic styling and can be extended for other uses.</p>
</div>

Solution

// solution required