Reputation:
I have the following CSS:
a.button:hover,
.mini-menu > li > a:hover {
xxx
}
Is there a way I can make this hover effect work for the button ONLY if the button does not have a class of "disabled"?
Upvotes: 1
Views: 92
Reputation: 1670
Besides :not()
- Another approach would be to leverage CSS Specificity and reset the styling with a higher scoring "disabled" class.
a.button.disabled:hover,
.disabled.mini-menu > li > a:hover {
xxx- disabled properties that won't be over ridden by below.
}
a.button:hover,
.mini-menu > li > a:hover {
xxx
}
Working demo http://jsfiddle.net/bKyr3/
Upvotes: 0
Reputation: 5283
thy is can be done by the :not(.disabled)
selector.
Set the css for all elements that don't have .disabled
class
The :not(selector)
selector matches every element that is NOT the specified element/selector.
Note:IE8 and earlier do not support the
Upvotes: 1
Reputation: 12815
Except :not
selector, which is suggested here, you can also simply override hover class for a.button
with disabled
class (may be usefull if you support IE7 and 8):
a.button:hover,
.mini-menu > li > a:hover {
xxx
}
a.button.disabled:hover {
//css to set non-hover style
}
Upvotes: 1
Reputation: 943579
You can use the negation pseudo-class : :not(selector)
a:not(.disabled).button:hover,
.mini-menu > li > a:not(.disabled):hover { ... }
(Requires a supporting browser.)
Upvotes: 1
Reputation: 53198
You can use the CSS3 :not()
selector, but of course this has cross-browser compatibility implentations:
a.button:not(.disabled):hover,
.mini-menu > li > a:hover {
xxx
}
Upvotes: 1