jQuery动画背景位置,不工作在ie

时间:2013-11-20 12:13:08

标签: jquery html css internet-explorer jquery-animate

我有一个小的jQuery动画功能,它可以在IE以外的所有浏览器中使用。这是我的代码: HTML:

<div class="container">
  <div class="bg"></div>
  <div class="bgHover"></div>
</div>

CSS:

.container{width:54px; height:54px;}
.bgHover{background: url("../images/shine.png") no-repeat scroll -150px 0 rgba(0, 0, 0, 0); width:54px; height:54px; position: absolute; top: 8px; left: 8px;}
.bg{background-color:black; width:54px; height:54px;}

jQuery的:

$(document).ready(function(){
            var $e = $(".container")
            timer = setInterval(function(){
                $e.find(".bgHover").stop().animate({backgroundPosition: 0},500,function(){
                    $e.find(".bgHover").css("background-position","-99px 0"); 
                    $e.find(".bgHover").animate({backgroundPosition: '99px 0'});
                });
            },2500);
        });

请找到以上代码,该代码适用于除IE之外的所有浏览器。

1 个答案:

答案 0 :(得分:0)

您需要使用

    css({
        "background-position-x" : "-99px",
        "background-position-y" : "0"

    ); 

但是IE8中的rmbr,在此之前,你需要使用其他一些脚本,我正在寻找它

修改

我相信这会对你有所帮助https://github.com/kbwood/backgroundpos