CSS LESS creating spacing variations

138 views Asked by At

I was wondering how to achieve the following CSS with LESS:

.spacingTop {
    margin-top: 8px;
}

.spacingRight {
    margin-right: 8px;
}

.spacingBottom {
    margin-bottom: 8px;
}

.spacingLeft {
    margin-left: 8px;
}

Should I do something with Iterations?

1

There are 1 answers

0
Raźnyy On BEST ANSWER

What you actually want to do? Becouse LESS CSS was created to organizate your code. This classes are totally diffrent. I suggest you to use mixins. For this i will use this following as example :

.margins( @top , @right , @bottom , @left)
{
    margin-top: @top;
    margin-left: @right;
    margin-bottom: @bottom;
    margin-left: @left;
}

... and use it later as following

.spacingTop
{
    .margins( 15px );
}

Hope it helps! :)