This specific task can be easily achieved using a simple CSS transition
, without requiring any Javascript (unless supporting older browsers is necessary, but the basic effect will still function):
Example: http://codepen.io/anon/pen/nzLkf (tested on Firefox29 and Chrome35)
CSS code
#onec-fourth {
width: 300px;
height: 300px;
border: 2px dashed #ddd;
-webkit-transition: all 0s linear 1s;
-moz-transition: all 0s linear 1s;
-ms-transition: all 0s linear 1s;
transition: all 0s linear 1s;
}
#onec-fourth:hover{
background-color:#F36DE1;
color:white;
-webkit-transition-delay: 0s;
-moz-transition-delay: 0s;
-ms-transition-delay: 0s;
transition-delay: 0s;
}
For a fade-out effect (after 1 second) check out http://codepen.io/anon/pen/AkCcm
(utilize transition: all 1s linear 1s
and transition: all 0s linear 0s
on :hover
):
simply adjust the values of transition-duration
and transition-delay
to your preference until reaching the desired outcome.
To explore more about CSS transitions, visit MDN