I have few div and all are red in color, I use 'red' as the class name. but among the div I want to apply extra class like class="red active" to give selected div extra style.
why this doesn't work
.red{
background: red;
}
.red .active{
background: green;
}
change your css for :
.red.active
.red .active (with a space between) means an element that has a class active and is the descendant (children, granchildren, etc.) of an element that has a class red. This is called the descendant selector.
You need .red.active (without a space). It means an element that has both a red and active class. This is a multiple class selector.
Recommended read:
Multiple Class / ID and Class Selectors from Chris Coyier
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With