jQuery Cycle插件 - 容器的自动高度

Ale*_*lex 9 javascript jquery jquery-cycle

我在一些div上使用循环插件,如下所示:

<div class="sections">
  <div class="Section"> <img /> text </div>
  <div class="Section"> <img /> text </div>
  <div class="Section"> <img /> text </div>
</div>
Run Code Online (Sandbox Code Playgroud)

所有.section div都有可变高度,基于它们的内容.如何使循环不将容器div(节)调整到最大子高度?相反,我希望容器在每个动画上调整大小到当前子高度.

Ale*_*lex 21

好吧,我设法通过在'after'事件上挂钩一个函数来做到这一点:

function onAfter(curr, next, opts, fwd) {
  var $ht = $(this).height();

  //set the container's height to that of the current slide
  $(this).parent().animate({height: $ht});
}
Run Code Online (Sandbox Code Playgroud)

在这里找到了这些信息:http: //forum.jquery.com/topic/jquery-cycle-auto-height


Tej*_*eni 12

设置containerResize选项0并尝试.更多选项的细节在这里.

  • 你必须使用完整版本,而不是精简版. (2认同)