Writing a loop that increments by a value other than 1 in Sass

后端 未结 4 711
有刺的猬
有刺的猬 2020-12-05 23:09

In SASS, a loop is written like so:

@for $i from 1 through 100 {
    //stuff
}

This would yield 1, 2, 3, 4... all the way to 100.

H

4条回答
  •  误落风尘
    2020-12-05 23:43

    It isn't in the documentation because it simply isn't implemented. What you want to do can be done with the @while directive.

    $i: 1;
    @while $i < 100 {
      // do stuff
      $i: $i + 2;
    }
    

提交回复
热议问题