With LESS, I'm trying to come up with a snappy way to calculate margins, paddings, and the like based upon defining an amount.
Currently, I'm specifying this:
.emSpacing(@string) {
@emSpacing: unit(@string / 16) + 0em;
}
and call it:
div {
.emSpacing(16);
margin-top: @emSpacing;
margin-bottom: 2em;
}
which outputs a margin-top of 1em. However, applying that .emSpacing(16) to the margin-bottom won't work without some math to get to that desired 2em.
Ideally, I'd like to do something like this:
div {
margin-top: @emSpacing(16);
margin-bottom: @emSpacing(32);
}
which, of course, doesn't work. Is there another solution on these simple lines which will work?