im正在使用Bootstrap轮播,该轮播显示来自数据库的图像。现在,我需要使用它在同一容器中显示下一个和上一个图像。Carousel正常工作,但不能在其中显示下一个和上一个图像 我尝试了This。但是获得图像如下。 谢谢您的回答。
给出了输出图像。Output im getting
$(document).ready(function(){
$scope.vehicleImageList = {};
$http.get('http://localhost:8087/mmg/api/v1/franchisevehicleimages/'+$scope.source, {
headers: {
XXXXXXXXXXXXXXXXx
}
}).then(function (results2) {
$scope.vehicleImageList = results2.data.data;
});
$(function(){
$('.carousel-control').click(function(e){
e.preventDefault();
$('#myCarousel').carousel( $(this).data() );
});
})
});
.carousel,
.carousel-inner,
.carousel-inner > .item {
overflow: hidden;
}
.carousel-inner:before {
position:absolute;
top:0;
bottom: 0;
right: 82%;
left: 0;
content:"";
display:block;
background-color: #fff;
z-index: 2;
}
.carousel-inner:after {
position:absolute;
top:0;
bottom:0;
right: 0;
left: 82%;
content:"";
display:block;
background-color:#fff;
z-index: 2;
}
.carousel-control.left, .carousel-control.right {
background: initial;
width: 30%;
color: #000;
z-index: 10;
top: -10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- image carousel -->
<div class="row">
<div class="item form-group">
<div class="col-md-11">
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item" ng-class="{active:!$index}" ng-repeat="list in vehicleImageList | unique:'name'">
<img src="./src/images/{{list.name}}" alt="Vehicle" style="height:150px;width:250px">
<!-- <div class="carousel-caption" style="color:black">
<h3 class="h3-responsive">Light mask</h3>
<p>First text</p>
</div> -->
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
使用引导程序很容易做到。
请参阅以下代码:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Carousel Example</h2>
<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>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="la.jpg" alt="Los Angeles" style="width:100%;">
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago" style="width:100%;">
</div>
<div class="item">
<img src="ny.jpg" alt="New york" style="width:100%;">
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</body>
</html>