【问题标题】:slide class not found in carousel in Twitter Bootstrap 3在 Twitter Bootstrap 3 的轮播中找不到幻灯片类
【发布时间】:2014-03-06 21:42:28
【问题描述】:

我在 twitter bootstrap 3 中制作轮播,但是当我使用“轮播幻灯片”类时,它会给出错误未知的类幻灯片。在我正在使用的代码下方。请指导我。

<div class="container">
    <div id="theCarousel" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner">
            <div class="item active">
                <img src="/images/carousel-1.jpg" alt="1" class="img-responsive"/>
            </div>
            <div class="item">
                <img src="/images/carousel-2.jpg" alt="2" class="img-responsive"/>
            </div>
            <div class="item">
                <img src="/images/carousel-3.jpg" alt="3" class="img-responsive"/>
            </div>
            <div class="item">
                <img src="/images/CG-carousel-4.jpg" alt="4" class="img-responsive"/>
            </div>
        </div>
    </div>
</div>

【问题讨论】:

  • 你是否包含了 bootstrap js 文件?
  • 是的,我包含 bootstrap.min.js 文件 bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/js/bootstrap.min.js", " ~/Scripts/js/bootstrap-carousel.js"));
  • 轮播初始化时绑定。仅将其视为选择器目的。如果您希望轮播在图像之间滑动,请添加幻灯片类
  • 我如何添加幻灯片类以及在哪里
  • 您的代码是正确的。什么时候报错?你初始化轮播了吗?看看这个:stackoverflow.com/questions/9985801/… 好像和你的问题有关

标签: jquery css twitter-bootstrap twitter-bootstrap-3


【解决方案1】:

您的代码是正确的.. 在我的系统中,这段代码运行良好..

Bootstrap 3 中没有“slide”类的定义。但是没有“Slide”类,轮播图像会发生变化而没有任何动画效果..

在你的代码中添加这个脚本

<script>
    $(document).ready(function () {
        $('.carousel').carousel();
    });
</script>

检查代码中的 Bootstrap CSS 和 JS 参考。 并检查参考文件的顺序

你可以按照这个顺序:-

  1. bootstrap.css
  2. bootstrap-theme.css
  3. jquery-1.9.1.js
  4. bootstrap.js

如果没有 JQ 库,脚本块将无法工作..所以正确添加 JQ 库文件..

并确保在脚本工作之前加载 JQ 文件。为此,您可以在页面顶部添加参考

【讨论】:

  • 谢谢!我遇到了这个问题,这是因为我在 jquery 之后包含了 bootstrap.css。这是解决问题的一种奇怪的方法。
猜你喜欢
  • 2012-04-16
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 2016-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-08-02
相关资源
最近更新 更多