简体   繁体   English

生成多个CSS类的CSS *

[英]Generate scss multiple css class*

I have the following css helper classes. 我有以下CSS助手类。 So my question is, is there better way to do that? 所以我的问题是,有更好的方法吗? or can i generate such a classes in scss to make it cleaner and better. 或者我可以在scss中生成这样的类以使其变得更干净更好。

Thanks. 谢谢。

.m-1 { margin: 1px !important; }
.m-2 { margin: 2px !important }
.m-3 { margin: 3px !important }
.m-4 { margin: 4px !important }
.m-5 { margin: 5px !important }
.m-6 { margin: 6px !important }
.m-7 { margin: 7px !important }
.m-8 { margin: 8px !important }
.m-9 { margin: 9px !important }
.m-10 { margin: 10px !important }

Using SASS 使用SASS

@for $i from 1 through 10 {
   .m-#{$i} { margin: 1px * $i !important; }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM