1. Overview
- I have a list of selectors that should always apply certain properties.
- Some selectors require additional properties to be added.
I'm struggling to find a way to achieve this without repeating code.
2. Minimal CSS Example (MCVE)
2.1. Expected CSS Output
.KiraFirst,
.KiraSecond,
.KiraThird {
color: red;
}
.KiraSecond {
background-color: yellow;
}
In the example above, .KiraSecond
is repeated twice. Is there a way to achieve the expected behavior without this repetition?
2.2. Using Stylus
- View live demo on stylus-lang.com
.KiraFirst
.KiraSecond
.KiraThird
color red
.KiraSecond
background-color yellow
This stylus code compiles to the expected CSS output, but the use of .KiraSecond
is duplicated.
I'm unsure of how to avoid this duplication. For instance, the following syntax did not produce the expected CSS:
.KiraFirst
.KiraSecond
background-color yellow
.KiraThird
color red
The result was:
.KiraFirst,
.KiraSecond {
background-color: #ff0;
}
.KiraThird {
color: #f00;
}
3. Resources I've Tried
- Stylus official documentation, specifically the Selectors section
- Stack Overflow questions related to Stylus
- Stylus GitHub issues