我使用Twitter Bootstrap 3创建了一个旋转木马,我无法让它正常工作。幻灯片似乎互相叠加,它不会循环通过它们。检查编码错误但没有找到。这是一个带有我的代码的Jsfiddle:(http://jsfiddle.net/N6Y4D/)
或者在这里:
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item-active">
<img src="img/slide1.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
<div class="item">
<img src="img/slide2.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
<div class="item">
<img src="img/slide3.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
<script src= "js/jquery-2.0.2.js"></script>
<script src= "js/bootstrap.js"></script>
</body>
答案 0 :(得分:3)
以下是完整的代码..在&#39; carousel-inner&#39;你写的是&#39; item-active&#39; ,它应该是&#39;项目有效&#39;两者都是单独的类。
<div id="myCarousel" class="carousel slide">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="item active"> // error was occurring here it should item active not item-active
<img src="img/slide1.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
<div class="item">
<img src="img/slide2.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
<div class="item">
<img src="img/slide3.png" style="height: 100%; width: 100%; display: block"/>
<div class="container">
<div class="carousel-caption">
<h1>Heading text</h1>
<p>Description</p>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>