且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

IE 9重置背景位置悬停时(IE漏洞?)

更新时间:2023-09-11 21:05:58

我可以建议下面的CSS-唯一的解决办法?

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;
}

如果你真的想它在IE9工作及以下(因为它在IE10做工精细),尝试动画 backgroundPosition 本身,而不是它的组件属性。

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});}
 );