我的网站需要一个简单的bootstrap轮播。我找到了上面的代码。然而,旋转木马的CSS高度似乎是个问题。 CODE与以下网站上的示例中的代码相同:
http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=carousel
我有什么:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap 3 Carousel</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style type="text/css">
.carousel{
background: #2f4357;
margin-top: 20px;
}
.carousel .item img{
margin: 0 auto; /* Align slide image horizontally center */
}
.bs-example{
margin: 20px;
}
</style>
</head>
<body>
<div class="bs-example">
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Carousel indicators -->
<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>
<!-- Wrapper for carousel items -->
<div class="carousel-inner">
<div class="item active">
<img src="../images/slide1.png" alt="First Slide">
</div>
<div class="item">
<img src="../images/slide2.png" alt="Second Slide">
</div>
<div class="item">
<img src="../images/slide3.png" alt="Third Slide">
</div>
</div>
<!-- Carousel controls -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
</div>
</body>
</html>
帮助?我不明白为什么会这样?
答案 0 :(得分:0)
图片未定义: jsfiddle.net/sdc9cpga
答案 1 :(得分:0)
轮播高度由图像决定,使用您的代码,我在路径中添加了一个图像并且工作正常。否则在这里添加一个定义的高度:.carousel-inner&gt; .item&gt; IMG