简体   繁体   English

Twitter Bootstrap Carousel不滑动

[英]Twitter Bootstrap Carousel Not Sliding

I ran into an interesting issue. 我遇到了一个有趣的问题。 I'm pretty sure that the answer is very simple, but I just couldn't figure it out so I thought I look for some help. 我很确定答案非常简单,但我无法理解,所以我想我寻求一些帮助。

Basically, my carousel doesn't slide. 基本上,我的旋转木马不会滑动。 It just switches image. 它只是切换图像。 I even tried copying the exact HTML from the bootstrap site into my own page and it still doesn't slide. 我甚至尝试将确切的HTML从引导站点复制到我自己的页面中,但它仍然没有滑动。 In application.js, the initialization is also has no argument. 在application.js中,初始化也没有参数。

// carousel demo
$('#myCarousel').carousel()

I notice that next and prev classes are added to each item when clicking pref/next button, but it doesn't seem to do the same thing on mine. 我注意到单击pref / next按钮时会将next和prev类添加到每个项目中,但它似乎对我的内容没有做同样的事情。 I didn't see anything wrong when I debugged either. 调试时我没有看到任何错误。

What am I missing? 我错过了什么? I tested this in both latest Chrome and Safari. 我在最新的Chrome和Safari中测试了这个。

您还必须添加bootstrap-transition以使滑动起作用,如下所示:

<script src="twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script>

I was having the same issue but with bootstrap v2.0.3 (which has transition bundled in), ended up adding the slide class to the carousel div 我有同样的问题,但使用bootstrap v2.0.3(已捆绑过渡),最终将幻灯片类添加到轮播div

<div id="myCarousel" class="carousel slide">

then you just call: 然后你打电话:

$('#myCarousel').carousel();

I think you need 我想你需要

$('#myCarousel').carousel('cycle');

Pls also see: How can I make the Bootstrap js carousel automatically cycle as soon as the page loads? 请参阅: 如何在页面加载后使Bootstrap js轮播自动循环?

Here is a working example. 这是一个有效的例子。 It's probably something minor your missing. 这可能是你失踪的一点点。 http://jsfiddle.net/chapmanc/Vza6F/1/ http://jsfiddle.net/chapmanc/Vza6F/1/

Do you just put that JavaScript in a <script> tag? 你只是把JavaScript放在<script>标签中吗?

<script>
    $('.carousel').carousel({
        interval: 1000
    })​;
</script>

check the css files that you have included. 检查您包含的css文件。 Try and add the bootstrap.css file as well in addition to bootstrap.min.css. 除了bootstrap.min.css之外,还尝试添加bootstrap.css文件。 It worked for me . 它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM