I’m trying to only apply the CSS :hover selector when two different classes are attached to a div. I’ve tried this, but this gets rid of the hover effect.
.accordionButton .cyan:hover{
color: cyan;
}
I also cant do this:
.accordionButton:hover, .cyan:hover{
color: cyan;
}
because I have two other colors I am trying to do this with as well.
Basically, is there any way to make the CSS apply only when one hovers over a div that is both an .accordionButton AND a .cyan?
You can combine class selectors by chaining them without spaces.
In the example below, the
:hoverdeclaration is applied only to elements with both classes:For reference, see MDN:
Target an element if it has more than one class applied.