Ramirez
Ramirez

Reputation: 193

CSS LESS creating spacing variations

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?

Upvotes: 1

Views: 140

Answers (1)

Raźnyy
Raźnyy

Reputation: 114

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! :)

Upvotes: 2

Related Questions