18

This is what I have:

.box{
    background:#FFF;
    -webkit-transition: background 0.5s;
}

.box:hover{
    background:#000;
}

But this appends to both onmouseover and onmouseout actions, but isn't there a way to control them? Something like:

-wekbkit-transition-IN: background 1s;
-webkit-transition-OUT: background 10s;
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Adam Halasz
  • 57,421
  • 66
  • 149
  • 213

2 Answers2

31

Just redifine your transition in the over pseudo element.

.box{
    background: white;
    -webkit-transition: background 5s;
}
.box:hover{
    background: olive;
    -webkit-transition: background 1s;
}

Look my http://jsfiddle.net/DoubleYo/nY8U8/

Yoann
  • 4,937
  • 1
  • 29
  • 47
0

Either use an animation (only in webkit currently), or use JS to add and remove the properties, they will still animate.

Rich Bradshaw
  • 71,795
  • 44
  • 182
  • 241