Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable hover event in CSS if element have class? [closed]

Is it possible to disable hover event in CSS if element have class?

like image 945
AhmedFaud Avatar asked Dec 15 '22 18:12

AhmedFaud


2 Answers

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>
like image 60
Turnip Avatar answered Dec 17 '22 08:12

Turnip


You can use pointer-events: none, but this will disable all pointer related events, including click.

a.class {
    pointer-events: none;
}
like image 20
Steve Sanders Avatar answered Dec 17 '22 07:12

Steve Sanders