nicksss
nicksss

Reputation: 157

How to make gradual colour change when hover with CSS?

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;
}

Upvotes: 8

Views: 16653

Answers (1)

Dhiraj
Dhiraj

Reputation: 1871

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

Upvotes: 16

Related Questions