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

后端 未结 4 710
有刺的猬
有刺的猬 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:17

    Other example more:

    .my-class {
        $step    : 5;
        $from    : ceil( 1 /$step);
        $through : ceil( 100 /$step);
        $unit    : '%';
    
        @for $i from $from through $through {
          $i : $i * $step;
          width: $i#{$unit};
        }
    }
    

提交回复
热议问题