Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make gradual colour change when hover with CSS?

Tags:

css

hover

I'm trying to make a gradual background colour change from normal to a hover colour, but, unfortunately, everything I've read and tried didn't work. This is the code I have:

.button-submit {
     color: #ffffff;
     cursor: pointer;
     display: inline-block;
     line-height: 35px;
     background: #5ea12b;
     padding: 0px 20px;
     vertical-align: middle;
     font-size: 18px;
     min-width: 80px;
     min-height: 35px;
     font-family: Light;
     border: 1px solid transparent;
     margin: 5px;
}
.button-submit:hover {
     background: #5ea12b;
     color: #FFFFFF;
}
like image 617
nicksss Avatar asked Mar 13 '16 16:03

nicksss


1 Answers

Use transition property:

EG:

.button-submit {
    background: #5ea12b;
    transition: background 0.5s ease-in-out;
}

And on hover, change the background color to little darker tone.

.button-submit:hover {
     background: #000;
}

CHECK THE DEMO

like image 123
Dhiraj Avatar answered Nov 09 '22 00:11

Dhiraj