Generate scss multiple css class*

I have the following css helper classes. 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.

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 }

Answers


Using SASS

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

Need Your Help

Initializing objects using this operator in constructors

c# asp.net-mvc-3 asp.net-mvc-4 constructor

As I was trying to implement code first approach using repository patterns in MVC, I have come across some difficulties as below: