2

I have a button with the button class button.ttfm2 but I want to change button[type="submit"]:hover this specific button:

At the moment my current code is:

.ttfm2 button[type="submit"]:hover {
background-color: #28AE47 !important;
}

What am i missing?

2
  • Check this link :stackoverflow.com/questions/15243656/… Commented Oct 7, 2015 at 7:03
  • General advice: Use helper classes on the submit button so that you don't need to use the attribute selector. Also, use the specificity of your selectors to control the order of the cascade to avoid having to use !important. Commented Oct 7, 2015 at 7:11

2 Answers 2

3

The right code would be:

button[type="submit"].ttfm2:hover {
   background-color: #28AE47; /* avoid using !important */
}

You were trying to select the button of type submit inside ttfm2 element using descendant selector but you need to use the multiple selector i.e. the button that has a class ttfm2

Sample Output:

button[type="submit"].ttfm2 {
  transition: all ease 2s;
}
button[type="submit"].ttfm2:hover {
  background-color: #28AE47;
}
<button type="submit" class="ttfm2">Test</button>
<button class="ttfm2">This will not work</button>

Sign up to request clarification or add additional context in comments.

Comments

0

a selector:

button[type="submit"].ttfm2:hover {
   background-color: #28AE47 !important;
}

Comments

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.