【问题标题】:jQuery animate background-position, not working in iejQuery动画背景位置,不适用于ie
【发布时间】:2013-12-04 10:20:06
【问题描述】:

我有一个小的 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 之外的所有浏览器中运行。

【问题讨论】:

  • 请记住,IE
  • @RajaprabhuAravindasamy:有什么解决办法吗?
  • 这可能对你有帮助,stackoverflow.com/questions/6993922/…
  • 什么IE版本?因为您的代码适用于 ie 9 和 10
  • @GabyakaG.Petrioli:是的,它在 IE8 中不起作用。

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


【解决方案1】:

你需要使用

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

    ); 

但是在IE8及之前的rmbr,需要用到其他一些脚本,我正在找

编辑:

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

【讨论】:

  • Dziewonski:如果有脚本,请分享。
猜你喜欢
  • 2011-07-07
  • 2011-03-01
  • 1970-01-01
  • 2011-07-27
  • 2011-05-03
  • 1970-01-01
  • 1970-01-01
  • 2013-08-16
相关资源
最近更新 更多