javascript - jquery animate 在 IE9 及更早版本中不起作用

标签 javascript jquery html css internet-explorer

我对 jquery 动画有疑问。它不适用于 IE9 及更早版本。我认为问题出在 css 的某个地方,因为正如我在 ie 中看到的那样,不透明度设置为 0。

Javascript

var $lead = $('.lead');
var height = $lead.height();
var totalHeight = height * numOfLeads;
function bounce() {
    var time = 400;
    var counter1 = 1;
    $($(".lead").get().reverse()).each(function() {
        setTimeout(function(el, counter1, height, totalHeight) {
            $(el).css({
                top: "-" + (totalHeight - (counter1 * height) + height) + "px",
                opacity: 0,
                display: "block",
                position: "relative"
            }).animate({
                top: "+=" + (totalHeight - (counter1 * height) + height) + "px",
                opacity: 1
            }, 1000, "easeOutBounce")
                    ;
        }, time, this, counter1, height, totalHeight);
        time += 400;
        counter1 += 1;
    });
}
bounce();

HTML

<div class="lead">
<div class="progress-bar">
    <div>
        <span class="first green end"></span>
        <span class="middle"></span>
        <span class="middle"></span>
        <span class="last"></span>
    </div>
    <span>Accepted</span>
</div>
<div class="product">Hypotek</div>
<div class="county">Ustecky</div>
<div class="change">
    <span>Changed</span>
    <div>22</div>
    <div>29</div>
    <div>38</div>
</div>

CSS

#leads{position: absolute;}
#leads, #leads div { z-index: 5;}
.lead { background: url("../images/lead_back_stripe.png") repeat-x scroll 0 0 transparent; height: 65px;}
.lead > div { float: left; padding-left: 20px; padding-top: 21px; width: 180px;}
.lead > div.progress-bar{width: 185px;}
.lead > div.product {width: 175px;}

你可以看到全部here

有人知道问题出在哪里吗?

最佳答案

长话短说:不透明度在 ie 中不起作用,据我所知,在 ie 中设置不透明度的唯一方法是 filter: alpha(opacity = X); with 0 < X > 100 ....这不适用于 jquery 动画

除了,也许这行得通:

$(el).animate({
        opacity:1
},{
    step: function( now, fx ) {
        var X = 100 * now; //like at half the animation, opacity is 0.5, so X becomes 50
        $(fx.elem).css("filter","alpha(opacity="+X+")");
    }
});

关于javascript - jquery animate 在 IE9 及更早版本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19005538/

相关文章:

css - 为什么我的图像在 Firefox 和 Chrome 中太左对齐

html - 导航链接的说明类不起作用

javascript - 为 WebSocket [握手] 制作一个 PHP 套接字服务器

javascript - 如何从使用 rjxs 从 API 获取值的服务返回映射字符串?

javascript - 如何知道哪个域使用 JS 向我的 C# 操作发送请求

javascript - 将嵌套 Knockout.js 组件与 RequireJs 结合使用

jquery - jQuery 可以监听浏览器事件吗?

javascript - 将 JSP 数据表转换为 Jquery 数据表

javascript - 当窗口从中间滚动到底部时 Plax.js 不工作

jquery - 为 "click"属性解除绑定(bind) "onclick"