Reputation: 607
I can't bealieve i found something that works both in IE8 and IE7 but fails in IE9. Here is the page i was working on: [Link to the site][1]. Notice how in IE9, on the side menu when hover a link the browser resets the background to background-position: 0 0
and only after this applys, the script animates it to background-position: -20px 0
(where i want it to go in the first place). Is anything that i've done wrong or there is a IE bug? Also need some help to fix it.
here is the script that i am applaying to IE brawsers only:
**
$('#nav_bar li')
.css( {backgroundPositionX:"-224px",
backgroundPositionY:"0px"} )
.mouseenter(function(){
$(this).stop().animate(
{backgroundPositionX:"-20px"},
{duration:550})
})
.mouseleave(function(){
$(this).stop().animate(
{backgroundPositionX:"-224px",
backgroundPositionY:"0px"},
{duration:550})
})
Thanks for the help!
[1]:
Upvotes: 3
Views: 611
Reputation: 324650
Might I suggest the following CSS-only solution?
#nav_bar li {
/* whatever you need for the background image */
background-position: -224px 0;
transition: background-position 0.55s ease;
-webkit-transition: background-position 0.55s ease;
}
#nav_bar li:hover {
background-position: -20px 0;
}
If you really want it to work in IE9 and below (since it does work fine in IE10), try animating backgroundPosition
itself, rather than its component properties.
$("#nav_bar li")
.css({backgroundPosition:"-224px 0"})
.hover(
function() {$(this).stop().animate({backgroundPosition:"-20px 0"},{duration:550});},
function() {$(this).stop().animate({backgroundPosition:"-224px 0"},{duration:550});}
);
Upvotes: 2