我使用的是 BS 3.0,问题是我已经添加了脚本和 slider 本身的所有代码,但它不旋转图像。这是js文件的顺序:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
<Script src="http://alvarotrigo.com/fullPage/vendors/jquery.slimscroll.min.js"></script>
此后还有更多。要添加图像,我有以下代码:
<div class="container-fluid">
<div class="row">
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="images/slide1.jpg" alt="..." class="img-responsive">
<div class="carousel-caption lead visible-lg visible-md" >
<h1 class="text-danger">Welcome To<span class="white-bg">Site</span></h1>
</div>
</div>
<div class="item">
<img src="images/slider_2.png" alt="..." class="img-responsive">
<div class="carousel-caption visible-lg visible-md" >
<h1 class="text-danger">Welcome To<span class="white-bg">site</span></h1>
</div>
</div>
<div class="item">
<img src="images/slider_3.png" alt="..." class="img-responsive">
<div class="carousel-caption lead visible-lg visible-md" >
<h1 class="text-danger">Welcome To<span class="white-bg">site</span></h1>
</div>
</div>
</div>
</div> <!-- Carousel -->
</div>
</div>
最佳答案
您可能忘记为 Bootstrap 添加触发器和 CSS 文件(如果没有 CSS 文件,它将无法工作,并且也不会在控制台中给出错误)
$('.carousel').carousel({
interval: 3000
})
这是一个工作 fiddle ,我添加了 CSS 库和 jQuery 代码来触发 slider :http://jsfiddle.net/43j8ebh6/1/
关于javascript - Bootstrap : home page slider not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33605394/