>目标
- 使轮播成为视口大小的 60% x 60%。
- 使所有图像的大小与幻灯片显示的大小相同。
- 使旋转木马流动。
有谁知道如何实现这一点?这对我来说似乎是一个顽固的问题。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
</head>
<body>
<div id="history-slideshow" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block w-100" src="https://d2z0k43lzfi12d.cloudfront.net/blog/vcdn215/wp-content/uploads/2017/06/15.06._Running-Stamina-1-800x510.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://www.shape.com/sites/shape.com/files/1200-woman-running-outside_1.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="/Virginian_banner.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#history-slideshow" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#history-slideshow" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
</body>
</html>
谢谢!!
更改下面的颜色代码以满足您的需求
/*
Removes white gap between slides - change to base color of slide images
*/
.carousel {
background:#F5F5F5;
}
.carousel-item .img-fluid {
width:60%;
height: 60%;
}
/*
anchors are inline so you need it make them block to go full width
*/
.carousel-item a {
display: block;
width:60%;
height: 60%;
}
.carousel-control-prev {
color:#036;
margin-left: -.5rem;
z-index: 10;
}
.carousel-control-next {
color:#036;
margin-right: -.5rem;
z-index: 10;
}
.carousel-control-prev:hover {
color:#0084FF;
}
.carousel-control-next:hover {
color:#0084FF;
}
如果你想为控件使用fontawesome图标,请使用这个
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<i class="fas fa-chevron-circle-left fa-2x"></i>
以前
<a class="carousel-control-next text-faded" href="#carouselExampleControls" role="button" data-slide="next">
<i class="fas fa-chevron-circle-right fa-2x"></i>
下一个
除了下面的 css 规则外,我还将所有图像都设为 Bootstrap .img-fluid
的成员。
html {
height: 100%;
width: 100%;
}
body {
height: 100%;
width: 100%;
display: block;
}
.carousel {
height: 60%;
width: 60%;
}
.carousel-item {
display: block;
width: 100%;
height: 100%;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
</head>
<body>
<div id="history-slideshow" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="https://d2z0k43lzfi12d.cloudfront.net/blog/vcdn215/wp-content/uploads/2017/06/15.06._Running-Stamina-1-800x510.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="https://www.shape.com/sites/shape.com/files/1200-woman-running-outside_1.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="/Virginian_banner.jpg">
<div class="carousel-caption">
<h3>HelloWorld</h3>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#history-slideshow" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#history-slideshow" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
</body>
</html>