Mahmoud
Mahmoud

Reputation: 1395

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 }

Upvotes: 0

Views: 569

Answers (1)

Michal Brašna
Michal Brašna

Reputation: 2323

Using SASS

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

Upvotes: 5

Related Questions