为什么Animate marginLeft不起作用?

时间:2016-09-22 12:16:30

标签: javascript jquery jquery-animate

我正在制作滑块但动画marginLeft不起作用,我无法弄清楚原因。

褪色与不透明也不起作用。

  $currentSlide.find('.content').animate({
    marginLeft: '-100%',
    opacity: 0
  }, speed);

  setTimeout(function() {
    $currentSlide.removeClass('active');
    $nextSlide.addClass('active');

    $nextSlide.find('.content').animate({
      marginLeft: '0%',
      opacity: 1
    }, speed);
  }, speed);

在这里你可以看到两张幻灯片($ currentSlide和$ nextSlide),其中第一张幻灯片应该淡出,动画marginLeft为-100%,第二张幻灯片可以做到,反之亦然。

[编辑]滑动点击白条

示例:https://codepen.io/anon/pen/dpNRqQ

[编辑]:这个例子来自我,但不应该工作!

1 个答案:

答案 0 :(得分:0)

发现失败:

变化

$currentSlide.find('.content').animate

$currentSlide.find('.slide-content').animate
相关问题