3

I need change button background color on hover.

My CSS on jsfiddle: CSS

My HTML :

<input type='button' class='btn btn-default btn-success btn-lg' value='test'/>

DEMO

user3272321
  • 59
  • 1
  • 1
  • 5
  • 2
    this is not your code, you ripped this from some website and expect us to alter it as per your needs. – Banana Jul 18 '14 at 08:27

5 Answers5

17

You can achieve it in the following way. This solution will work if you add this class at the bottom of your CSS.

.btn:hover
{
background-image:none;
background-color:#ff00ff;
}

If you keep this class in top of the other styles, you need to use important keyword to overcome with other styles like below.

.btn:hover
{
background-image:none !important;
background-color:#ff00ff !important;
}

DEMO

Suresh Ponnukalai
  • 13,820
  • 5
  • 34
  • 54
2

you might use this solution as !important make the CSS invalid. In this case all the type= button which have .btn class will only affected.

input[type="button"].btn:hover{background:red;}
Kheema Pandey
  • 9,977
  • 4
  • 25
  • 26
  • @user3272321 I would suggest you to not used the `!important` in your CSS file as in w3c validator your CSS file will be failed. you can try the above approach. much better way to handle. – Kheema Pandey Jul 18 '14 at 08:28
1

you can achieve using the below

.btn:hover{
//apply styles here
}
0

this is really easy, you just have to add the css selector :hover

for example:

.btn-success:hover{
    color: #ffffff;
   background-color: #51a351;
}
MeMTn
  • 93
  • 1
  • 13
-3

You can use :hover with the class for the mouse hover event. Like if you want you can use:

btn:hover {
   color:blue; 
}

best of luck

Faran Khan
  • 1,495
  • 4
  • 14
  • 26