javascript - jCarousel 垂直滚动不起作用

标签 javascript jquery html css jcarousel

$(function() {
 $('.jcarousel')
				.jcarousel({
					auto: 1,
					animation: {
						duration: 3000,
						easing:   'linear',
					},
					vertical: true,
					wrap: 'last'
			}).jcarouselAutoscroll({
					interval: 3000,
					target: '+=1',
					autostart: true
				});
});
ul li {
  list-style-type: none;
}

.jcarousel {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 88px;
}

.jcarousel li {
    float: left;
    width: 100%;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jcarousel/0.3.4/jquery.jcarousel.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
  <div class="jcarousel">
    <ul>
      <li>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
        survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
        publishing software like Aldus PageMaker including versions of Lorem Ipsum.</li>
      <li>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
        survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
        publishing software like Aldus PageMaker including versions of Lorem Ipsum.</li>
      <li>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
        survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
        publishing software like Aldus PageMaker including versions of Lorem Ipsum.</li>
      <li>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
        survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
        publishing software like Aldus PageMaker including versions of Lorem Ipsum.</li>
      <li>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
        survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
        publishing software like Aldus PageMaker including versions of Lorem Ipsum.</li>
    </ul>
  </div>
</div>

ul 容器在顶部位置显示计算出的样式变化,但轮播的内容不滚动。请帮忙。这是jCarousel Version .这是我的 Codepen .只需要这最后一 block 垂直滚动即可工作。

最佳答案

它不滚动,因为你缺少这个 CSS:

.jcarousel ul {
    position: relative;
}

如果您查看 DOM 检查器,它正在应用 topleft 样式,但没有任何移动。那是因为样式应用于 ul 但它需要 position: relative。既然它滚动以获得您想要的效果,您将需要更多地调整您的高度和其他东西,但现在您应该开始看到预期的结果。

编辑:抱歉,我没有注意到您明确表示您已经看到样式已经被应用。无论哪种方式添加上面的 CSS,它应该开始工作。

关于javascript - jCarousel 垂直滚动不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34799329/

相关文章:

javascript - 算法查找深度并按顺序插入 JSON 数组

javascript - 我可以将任何指标添加到 highcharts 中的任何图表类型吗?

javascript - 为什么我的 Owl Carousel 在我的第一组中不起作用?请问我的eero在哪里?

javascript - 使用正则表达式删除表格内的宽度标签

javascript - Touchend 第二次在 touchstart 上触发

javascript - 使用浮点值制作 math.random

jquery - 取消绑定(bind)点击,但保留事件 PreventDefault();

javascript - HTML5 视频忽略 z-index

javascript - 检测特定 div 的任何嵌套元素中的单击事件

javascript - 调整表格大小时如何通过在字符串中间放置省略号来 chop 字符串