O
O
Oleg Morev2018-04-03 16:05:33
Less
Oleg Morev, 2018-04-03 16:05:33

Is it possible in Less to extend the beginning of the class name to child elements?

Good afternoon, there is such a code, the presence of a wrapper is required.

.wrapper {
    .less {

        &-level-1 &-level-2 {
            color: red;
        }
    }
}

Question:)
From level-1, everything will clearly compile to .less-levlel-1.
What about level 2? something to get .less-level-2, provided that it is a child of .less-level-1

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Radkov, 2018-04-03
@paulradzkov

If you need to end up with the selector `.less-level-1 .less-level-2 { ... }` then the only option is:

.less {
    &-level-1 {
       display: block; 
    }
    
    &-level-1 &-level-2 {
        display: block;
    }
}

D
Dmitry Tallmange, 2018-04-03
@p00h

The documentation has comprehensive examples. It's good to look into it sometimes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question