Add unit after each space separated value in LESS mixin

37 Views Asked by At

I have a mixin in LESS that has two variables as perimeters and that has to output a PX and a REM value.

This is the mixin:

.rem (@attr, @val) {
 @{attr}: @val * 1px;
 @{attr}: (@val * 1rem) / @baseFontSize;
}

With the @baseFontSize: 10;

If i write something like

.foo { .rem(margin, 1 2); }

I want it to output

.foo {
 margin: 1px 2px;
 margin: 0.1rem 0.2rem;
}

It works when the @val is only one value. How can i add the 'px' and 'rem' to every space separated value?

0

There are 0 best solutions below