我试图制作一个滑块并且它不起作用我认为我的按钮有问题,有人可以告诉我为什么吗? 我是新来的,所以我不知道出了什么问题......
这是我的代码:
`<head>
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
</head>
<body>
<div id="carousel-example-generic" class="carousel slide" data- ride="carousel">
<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>
<div class="carousel-inner">
<div class="item active">
<img src="http://placehold.it/600x400" alt="...">
<div class="carousel-caption">
</div>
</div>
<div class="item">
<img src="http://placehold.it/600x400" alt="">
<div>
...
</div>
</div>
<div class="item">
<img src="http://placehold.it/600x400" alt="">
<div>
...
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
<script src="js/jquery.js"></script>
<script src="js/bootstrap.js"></script>
</body>`
答案 0 :(得分:1)
以下是工作代码http://plnkr.co/edit/Xt0EhyVFNTgU3i8rvxHz?p=preview
<!doctype html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
</head>
<body>
<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" role="listbox">
<div class="item active">
<img src="http://placehold.it/600x400" alt="...">
</div>
<div class="item">
<img src="http://placehold.it/600x400" alt="...">
</div>
<div class="item">
<img src="http://placehold.it/600x400" alt="...">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" 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="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
</body>
我不确定为什么你有单引号
`<head>
</body>`
和
'data- ride='
有一些额外的空格。