How to do multiple class selectors in Stylus CSS pre-processor
Asked Answered
I

2

5

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

Indusium answered 17/10, 2013 at 9:24 Comment(0)
P
11

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}
Park answered 25/11, 2013 at 8:13 Comment(0)
O
-4

The right way:

.class
  &A&
    &B
      color red
Oppose answered 10/7, 2015 at 22:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.