Denis Seletkov
Denis Seletkov

Reputation: 47

LESS: combine properties (rules) with same value

I am using LESS CSS preprocessor. For example if there are two (or more) rules with same value

.my-class {
    border-top: 2px solid @main-bg-color - #123456;
    border-bottom: 2px solid @main-bg-color - #123456;
}

can I combine those two into one somehow like this?

.my-class {
    border-top, border-bottom: 2px solid @main-bg-color - #123456;
}

UPDATE: You shouldn't be concentrated on the props (border) I wrote just as example. I'd like to know if there's any way to combine any multiple props with same value. If there is no way to do so, please say it explicitly.

Upvotes: 1

Views: 684

Answers (2)

Denis Seletkov
Denis Seletkov

Reputation: 47

As @seven-phases-max says, there is no way to combine several props with same value in LESS. Use variables or mixins instead.

Upvotes: 0

Mark
Mark

Reputation: 532

Why not just use something like:

.my-class {
    border:  2px solid @main-bg-color - #123456;
    border-width: 2px 0;
}

Upvotes: 1

Related Questions