为什么fadeIn和animate不会同时发生?

时间:2011-06-14 22:44:18

标签: javascript jquery html css animation

为什么动画会在执行之前等待fadeIn完成,有人可以为我解释一下吗?

//Price Navigation FadeIn

$('#header-base > ul').hide().css({'top':'50px'});

$('#header-base > ul').fadeIn(500);
$('#header-base > ul').animate({'top':'0px'});

我希望fadeIn和animate同时发生。

2 个答案:

答案 0 :(得分:4)

问题是动画会自动放入效果队列中。您可以通过提供queue设置来更改此设置:

$('#header-base > ul').animate({top: '0px'}, {queue: false});

请参阅animate API

答案 1 :(得分:0)

不确定为什么它们不会同时发生,但快速修复就是

  1. 将元素的不透明度设置为0
  2. 显示元素
  3. 为您的动画功能添加不透明度淡入效果......
  4. 也许就像......

    $('#header-base > ul').css({'top':'50px', 'opacity':'0'});
    $('#header-base > ul').animate({top:'0px', opacity: 100}, 500);