我想为Bootstrap 4.1进行轮播覆盖,但是.carousel-control-prev-icon和carousel-control-next-icon无法正常工作。我如何运行图标?不适用于每个幻灯片元素。仅一个覆盖层,但覆盖幻灯片。 在html代码下方;
<!-- Start Banner-->
<section id="banner">
<div class="container-fluid">
<div class="row">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="bg-overlay">try fixed overlay</div>
<div class="carousel-item active">
<img class="d-block w-100" src="resources/images/image-1.jpg" alt="image slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="resources/images/image-2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="resources/images/image-3.jpg" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Önceki</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Sonraki</span>
</a>
</div>
</div>
</div>
css代码下方;
.bg-overlay {
background-color: rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
z-index: 2;
}
答案 0 :(得分:1)
在CSS文件中,您可以覆盖Bootstraps默认类。您可以直接将两个箭头css作为目标,以为其赋予更大的z-index
值。
示例:
.carousel-control-prev {
left: 0;
z-index: 3;
}
和
.carousel-control-next {
right: 0;
z-index: 3;
}
这会将箭头带到叠加层上方,并使它们可点击。
答案 1 :(得分:1)
在此示例中,下一个和上一个按钮具有叠加样式:
//////////////////////
<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">
</div>
<div class="item">
<img src="chicago.jpg" alt="Chicago">
</div>
<div class="item">
<img src="ny.jpg" alt="New York">
</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>
//////////////////////