【发布时间】:2020-05-18 01:52:26
【问题描述】:
我正在检查一些过去的 SO 帖子,但没有一个对我有帮助。我的问题是我的字幕被推到不再可见的地步。这可能是由于我的图像大小不同。 无论我使用什么尺寸的图片,我怎样才能让每张幻灯片的标题都显示在轮播的中心(固定位置)?
这是我目前所拥有的:http://www.bootply.com/KcWhRKSTxi
我尝试过的:之前提到的 SO 帖子尝试使用 margin-bottom 作为标题。我尝试使用 margin-bottom 来提升我的字幕,但有两个问题:(1)这不是响应式的和(2)一些字幕低于其他字幕。如果您检查我的引导链接,第二个滑块中的标题是可见的,因为图像是最小的(垂直而言)。换句话说,即使我使用了margin-bottom,一些字幕也会比其他字幕高/低。在我当前的实现中,您不会看到图像 1 或 3 上的标题,因为它们被推到 3 个点(图像选择器)下方。
这是我的代码:
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</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">
<div class="item active peopleCarouselImg">
<img class="peopleCarouselImg" src="https://images.unsplash.com/photo-1440637475816-2e8bf1d4b6f3?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=9000dbcc94e0bad6c5005dc1d867b105">
<div class="carousel-caption">
<h3>Caption Text</h3>
</div>
</div>
<div class="item">
<img class="peopleCarouselImg" src="https://images.unsplash.com/photo-1446645681877-acde17e336a9?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=d8507a72935161039a62fbd8bba41283">
<div class="carousel-caption">
<h3>Caption Text</h3>
</div>
</div>
<div class="item">
<img class="peopleCarouselImg" src="https://images.unsplash.com/photo-1443808709349-353c8b390400?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=ae16ad1553fa2305bdab4a73f583a725">
<div class="carousel-caption">
<h3>Caption Text</h3>
</div>
</div>
</div>
<!-- Controls -->
<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> <!-- Carousel -->
<script src="js/jquery-2.2.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
.carousel {
max-height: 600px;
overflow: hidden;
}
.item img {
min-width: 100%;
height: auto;
}
.carousel-caption {
margin-bottom: 100px;
}
【问题讨论】:
标签: html css twitter-bootstrap-3