我几乎是编码的新手,我一直试图在引导程序上做一个滑块,但是它并没有真正起作用,因为它变得像背景
继承我的HTML
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class= "container">
<div class="navbar-header">
<a class="navbar-brand" href"#">
<img src="img/logowine.png" alt="winelogo">
</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#mynavbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="mynavbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active">
<a href="#">Home</a>
</li>
<li>
<a href="#about">About </a>
</li>
<li>
<a href="#product">Products</a>
</li>
<li>
<a href="#contact">Contact</a>
</li>
</ul>
</div>
</div>
</div>
<div id="myCarousel" class="carousel slide" data-ride="carousel" >
<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" role="listbox">
<div clas="item active">
<img src="img/carousel1.jpg" alt="portdicksonrj" class="img-responsive">
</div>
<div clas="item">
<img src="img/carousel2.jpg" alt="portdicksonrjice" class="img-responsive">
</div>
<div clas="item">
<img src="img/carousel3.jpg" alt="portdicksonrjlemon" class="img-responsive">
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
$("#carousel").carousel();
</script>
</body>
它出来就像
this
和
this
答案 0 :(得分:1)
您错过了分类的拼写,只需将 HTML clas
更改为class
即可解决您的问题。
NB:另外请确保您添加 Bootstrap CSS
NB:我编辑您的问题所以现在它运作良好。
看看我的Bootstrap Carousel。
.carousel-inner > .item > img,
.carousel-inner > .item > a > img {
width: 70%;
margin: auto;
}
.item img {
height: 400px !important
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
<br>
<div id="myCarousel" class="carousel slide" data-ride="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>
<li data-target="#myCarousel" data-slide-to="3"></li>
<li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="https://upload.wikimedia.org/wikipedia/commons/4/47/Goole.jpg" alt="Chania 1" width="460" height="345">
</div>
<div class="item">
<img src="https://peterwardhomes.files.wordpress.com/2014/12/goole-area-shot_005.jpg" alt="Chania" width="460" height="345">
</div>
<div class="item">
<img src="http://www.telegraph.co.uk/content/dam/Travel/Destinations/Europe/France/Nice/Nice-nightlife-coastline-xlarge.jpg" alt="Flower 1" width="460" height="345">
</div>
<div class="item">
<img src="http://i.telegraph.co.uk/multimedia/archive/01858/nice3_1858695b.jpg" alt="Flower" width="460" height="345">
</div>
<div class="item">
<img src="http://eastriding.limehouse.co.uk/events/21318/images/highresRGB/2376387_0_1.jpg" alt="Flower" width="460" height="345">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
答案 1 :(得分:0)
试试这段代码..
<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="img/carousel1.jpg" alt="First Slide">
</div>
<div class="item">
<img src="img/carousel1.jpg" alt="Second Slide">
</div>
<div class="item">
<img src="img/carousel1.jpg" 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>