Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fade out but not fade in

How do I use CSS3 to fade out but not in. I.E. when I apply a class to an element I want the background to change color immediately with no delay or transition, and when I remove it I want the background to fade out according to a transition. I know it should be simple but i haven't managed to figure it out yet.

like image 751
user1572039 Avatar asked Aug 12 '12 21:08

user1572039


1 Answers

Specify the transition times for the element with and without the class.

.el {
    background: red;
    -webkit-transition: background .5s;
}
.el.hover {
    background: blue;
    -webkit-transition: 0;
}​
like image 131
JDavis Avatar answered Sep 22 '22 15:09

JDavis