玩scss功能

时间:2017-04-23 08:44:23

标签: function for-loop sass

所以我设置了以下代码。为什么最后一个标签没有颜色从灰色变为红色?当我向totalTabs变量添加1时,它确实会改变颜色,但这对我来说似乎很奇怪。 也许这在某个地方是一个小错字,但我没有看到它......

import_meta_graph()

到目前为止的造型......

<div class="tabs">  
  <input id="tab1" type="radio" name="tabs" checked/>
  <input id="tab2" type="radio" name="tabs"/>
  <input id="tab3" type="radio" name="tabs"/>
  <input id="tab4" type="radio" name="tabs"/>
  <div class="tabs__labels">
    <label for="tab1">tab 001</label>
    <label for="tab2">tab 002</label>
    <label for="tab3">tab 003</label>
    <label for="tab4">tab 004</label>
  </div>
  <div class="tabs__items">
   <div class="tabs__item">lorem ipsum dolor tab 001</div>
   <div class="tabs__item">lorem ipsum dolor tab 002</div>
   <div class="tabs__item">lorem ipsum dolor tab 003</div>
   <div class="tabs__item">lorem ipsum dolor tab 004</div>
 </div>

2 个答案:

答案 0 :(得分:0)

This line:

@for $i from 0 to $totalTabs {

Should be the following:

@for $i from 0 through $totalTabs {

The to keyword stops the loop at 1 index short of the length of your list.

答案 1 :(得分:0)

改变&#39;到&#39;在&#39;通过&#39;解决了这个问题...感谢您的评论