Files
freeCodeCamp/curriculum/challenges/chinese/03-front-end-libraries/sass/use-for-to-create-a-sass-loop.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.6 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
587d7dbe367417b2b2512bb9 Use @for to Create a Sass Loop 0 使用@for创建Sass循环

Description

@for指令在循环中添加样式非常类似于JavaScript中的for循环。 @for以两种方式使用:“ @for ”或“ @for ”。主要区别在于“从头到尾” 排除了结束号码,“从头到尾” 包括结束号码。这是一个开始最后的例子:
@for $ i从1到12 {
.col - {$ i} {width100/ 12 * $ i; }
}
#{$i}部分是将变量( i 与文本组合成字符串的语法。当Sass文件转换为CSS时它看起来像这样
.col-1 {
宽度8.33333;
}

.col-2 {
宽度16.66667;
}

...

.col-12 {
宽度100;
}
这是创建网格布局的有效方法。现在您有12个可用作CSS类的列宽选项。

Instructions

写一个@for指令它接受一个从1 6的变量$j 。它应该创建5个名为.text-1.text-5 ,其中每个类的font-size设置为10px乘以索引。

Tests

tests:
  - text: 您的代码应使用<code>@for</code>指令。
    testString: assert(code.match(/@for /g));
  - text: 您的<code>.text-1</code>类的<code>font-size</code>为10px。
    testString: assert($('.text-1').css('font-size') == '15px');
  - text: 您的<code>.text-2</code>类的<code>font-size</code>为20px。
    testString: assert($('.text-2').css('font-size') == '30px');
  - text: 您的<code>.text-3</code>类的<code>font-size</code>为30px。
    testString: assert($('.text-3').css('font-size') == '45px');
  - text: 您的<code>.text-4</code>类的<code>font-size</code>为40px。
    testString: assert($('.text-4').css('font-size') == '60px');
  - text: 您的<code>.text-5</code>类的<code>font-size</code>为50px。
    testString: assert($('.text-5').css('font-size') == '75px');

Challenge Seed

<style type='text/sass'>



</style>

<p class="text-1">Hello</p>
<p class="text-2">Hello</p>
<p class="text-3">Hello</p>
<p class="text-4">Hello</p>
<p class="text-5">Hello</p>

Solution

// solution required