Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 746
Yami Avatar asked Aug 05 '11 10:08

Yami


1 Answers

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;
}
like image 196
Nathan Strutz Avatar answered Oct 03 '22 03:10

Nathan Strutz