This kind of task can be easily realized with a simple CSS transition
, no Javascript is needed (unless you need to support older browsers, but the basic effect will work anyway):
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) see instead http://codepen.io/anon/pen/AkCcm
(use transition: all 1s linear 1s
and transition: all 0s linear 0s
on :hover
):
just play with with transition-duration
and transition-delay
values as you prefer, until you achieve the optimal result.
Further information on CSS transitions can be found on MDN