Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SCSS值倍数_Css_Integer_Sass - Fatal编程技术网

SCSS值倍数

SCSS值倍数,css,integer,sass,Css,Integer,Sass,我正在尝试与SCS合作。我基本上想要它,这样我就可以有任何利润,每5倍。比如我可以写m10 m15 m20 m25等等。。。它将创造利润:10px;利润率:15px;等等 到目前为止,我得到了: @for $margin from 0 through 100 { .m#{$margin} { margin: 1px * $margin } } 但是这使得所有的数字都在5的倍数之间,这是不理想的。是否可以只渲染5到100的倍数的边距 高级版谢谢。我建议另一种方式,使用: 然后可以为任何元素创

我正在尝试与SCS合作。我基本上想要它,这样我就可以有任何利润,每5倍。比如我可以写m10 m15 m20 m25等等。。。它将创造利润:10px;利润率:15px;等等

到目前为止,我得到了:

@for $margin from 0 through 100 {
  .m#{$margin} { margin: 1px * $margin }
}
但是这使得所有的数字都在5的倍数之间,这是不理想的。是否可以只渲染5到100的倍数的边距


高级版谢谢。

我建议另一种方式,使用:

然后可以为任何元素创建自定义页边距:

h1   { @include custom-margin(10px); }
span { @include custom-margin(0); }
.box { @include custom-margin(5px); }

写循环时,不要考虑您想要的边距大小,而要考虑您需要多少边距:

@for $margin from 0 through 20 {
  .m#{$margin * 5} { margin: 5px * $margin }
}

您可以这样做:

@for $margin from 0 through 100 {
  @if $margin % 5 == 0 {
    .m#{$margin} { margin: 1px * $margin }
  }
}

“Hi think”是您所寻找的。

注意不要落入此陷阱:
@for $margin from 0 through 100 {
  @if $margin % 5 == 0 {
    .m#{$margin} { margin: 1px * $margin }
  }
}