0

I have a button with class MyButton defined somewhat like this:

.MyButton{
 color:black;
 background:white;}

.MyButton:hover{
 color:white;
 background:black;}

This button class is for a pager button and when the pager is at bounds, I add this class to it:

.ButtonDisabled{
 opacity:0.3}

The issue is that if the user mouses over the button, it still inherits from the MyButton:hover style.

I know I could control all this with jquery to solve the hovering issue but I'm wondering if there's a way to prevent the hover class from triggering when the button also has the class ButtonDisabled.

Thanks.

2 Answers 2

4
.MyButton:hover{
 color:white;
 background:black;

}

// has more specificity than above selector, so it will stop previous hover effect
.MyButton.ButtonDisabled:hover{
 // write your configs
}
Sign up to request clarification or add additional context in comments.

Comments

0

Perhaps adding

.ButtonDisabled:hover{...}

would help you

1 Comment

The problem is that there are several other types of buttons, and so while the ButtonDisabled class sometimes applies to MyButton, it also applies to MyOtherButton and so the hovering of ButtonDisabled can take several forms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.