【问题标题】:Why does Animate marginLeft does not work?为什么动画 marginLeft 不起作用?
【发布时间】:2016-09-22 12:16:30
【问题描述】:

我正在构建一个 Slider,但动画 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 ),其中第一个 Slide 应该以动画的 marginLeft 为 -100% 淡出,而第二个 Slide 应该反之亦然。

[编辑] 滑动点击白条

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

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

【问题讨论】:

    标签: javascript jquery jquery-animate


    【解决方案1】:

    发现失败:

    改变

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

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

    【讨论】:

      猜你喜欢
      • 2020-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多