U
U
uRoot2020-12-10 16:51:35
Sass
uRoot, 2020-12-10 16:51:35

How to generate classes in SCSS?

I want to generate classes like: .mb-1, .mb-2, .mb-3 etc.
Where .mb-1 { margin-bottom: 1px; } .mb-2 { margin-bottom: 2px; } .mb-3 { margin-bottom: 3px; } etc.
And then also for margin-top by analogy. Do not tell me how to do it? I once did, but haven't used SCSS for a long time and forgot. I stopped at

@for $i from 1 through 12 {
    .mb-#{$i} { margin-bottom: $i; }
  }
But it doesn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2020-12-10
@uroot

Pixels forgot:

@for $i from 1 through 12 {
    .mb-#{$i} {
        margin-bottom: #{$i}px;
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question