문제

How do you do/can you do this in Stylus

.classA.classB {
    color: red;
}

Note, I do mean .classA.classB not .classA .classB (they're different)

I thought this would do it

.classA
    .classB
        color red

But that does this (which makes sense I guess)

.classA .classB{color:#f00}

I realise I can do this

.classA.classB
    color red

But that doesn't feel very "Stylus" and would become clumsy as/if you nested further

Thanks Jim

도움이 되었습니까?

해결책

You should use parent reference there — use an ampersand symbol (&) to define where the parent selector would go:

.classA
    &.classB
        color red

this would render to

.classA.classB{color:#f00}

다른 팁

The right way:

.class
  &A&
    &B
      color red
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top