Is it possible to disable hover event in CSS if element have class?
You could use the :not()
selector:
.myElement {
display: inline-block;
padding: 10px;
border-radius: 4px;
background: #CADE75;
text-decoration: none;
color: #6D6D6D;
}
/* important bit */
.myElement:not(.dontHover):hover {
background: #b5d335;
}
<a href="#" class="myElement">An element that hovers</a>
<a href="#" class="myElement dontHover">An element that doesn't</a>
You can use pointer-events: none
, but this will disable all pointer related events, including click.
a.class {
pointer-events: none;
}
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