I’m trying to set an hover effect using jqueryUI’s addClass() and removeClass().
This is what I came up with: http://jsfiddle.net/5aS77/ .
As you can see, ‘onmouseout’, the background becomes white for a time and then ‘jumps’ to blue again.
I just want the animation to go from blue to pink and vice verse without any ‘interruptions’.
I know it is possible with CSS3, and I did try it already though it has 2 main cons:
1) Not all browsers support the transition property.
2) It doesn’t have an onmouseout effect. (though it can be achieved with some JS.)
The white flash is because jQuery doesn’t have a base colour to animate from as the background-color is set on the
.navclass and not the<a>elements.You can edit the rules as follows to remove the white flash.
Also, if you want, here is a slightly cleaner implementation of the jQuery:
With this, the
.a_hoverclass can be removed, although you still need thebackground-color:blueon the.nav arule to avoid the initial white flash. The other properties in the.a_hoverare not needed since they already exit on the.nav arule.