Alex Jj
Alex Jj

Reputation: 1393

How to fade out after hover is done using CSS

I have have an image which its background color changes when hover.

It takes 1 second to change the colour, but as soon as the courser moves out of the image it changes back without any effect.

How can I have an effect for to fade out the background colour?

CSS:

.latestTrack {
    margin:80px 0 0 0 !important;
}
.latestTrack img {
    float:right;
    margin-right:50px !important;
}
.latestTrack img:hover
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    -ms-transition: all 1s ease;
    transition: all 1s ease;
    background-color:#f7710f;

}

HTML:

 <img src="img/SocIco/soundcloud-large.png" />

Upvotes: 7

Views: 32554

Answers (1)

dsgriffin
dsgriffin

Reputation: 68616

You forgot the easing out part:

.latestTrack img {
   float:right;
   margin-right:50px !important;
   -webkit-transition: all 1s ease-out;
   -moz-transition: all 1s ease-out;
   -o-transition: all 1s ease-out;
   -ms-transition: all 1s ease-out;
   transition: all 1s ease-out;
}

jsFiddle example here.

Upvotes: 18

Related Questions