Yami
Yami

Reputation: 81

Nested pseudoclasses in Less css

I am trying to use LESS CSS to write my CSS but i got a problem with nested pseudoclasses I

.class1 { 
        &:nth-of-type(2n) {  
            .class2{  
            } 
        } 
    }

the output is:

.class1.class2:nth-of-type(2n) {}

but I want to have this:

.class1:nth-of-type(2n) .class2{}

Any ideas?

Upvotes: 8

Views: 4789

Answers (1)

Nathan Strutz
Nathan Strutz

Reputation: 8123

Not an issue. You probably had a version of LESS CSS that did not produce the correct code. Try the online less converter and see that it works fine. Here is what I get:

(in)

.class1 { 
  &:nth-of-type(2n) {  
    .class2{  
      x:1;
    } 
  } 
}

(out)

.class1:nth-of-type(2n) .class2 {
  x: 1;
}

Upvotes: 3

Related Questions