将这段代码轮播中下方小方块改成圆点<div class="col-md-6"> <div id="myCarousel" class="carousel slide" data-interval="3000" > <ul class="carousel-indicators"> <li data-target="#myCarousel" data-slide-to="0" class="active"><> <li data-target="#myCarousel" data-slide-to="1"><> <li data-target="#myCarousel" data-slide-to="2"><> </ul> <div class="carousel-inner"> <div class="carousel-item active"> <img src="img/B1.jpg" class="d-block w-100" alt="First slide"> </div> <div class="carousel-item"> <img src="img/B2.png" class="d-block w-100" alt="Second slide"> </div> <div class="carousel-item"> <img src="img/B3.png" class="d-block w-100" alt="Third slide"> </div> </div> <a class="carousel-control-prev" href="#myCarousel" data-slide="prev"> <span class="carousel-control-prev-icon"></span> </a> <a class="carousel-control-next" href="#myCarousel" data-slide="next"> <span class="carousel-control-next-icon"></span> </a>
时间: 2023-07-19 11:49:40 浏览: 244
可以将ul标签中的class属性改成"carousel-indicators d-flex justify-content-center", 然后将li标签中的内容改成圆点的html代码,如下所示:
<div class="col-md-6">
<div id="myCarousel" class="carousel slide" data-interval="3000" >
<ul class="carousel-indicators d-flex justify-content-center">
<li data-target="#myCarousel" data-slide-to="0" class="active"><span class="dot"></span></li>
<li data-target="#myCarousel" data-slide-to="1"><span class="dot"></span></li>
<li data-target="#myCarousel" data-slide-to="2"><span class="dot"></span></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/B1.jpg" class="d-block w-100" alt="First slide">
</div>
<div class="carousel-item">
<img src="img/B2.png" class="d-block w-100" alt="Second slide">
</div>
<div class="carousel-item">
<img src="img/B3.png" class="d-block w-100" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#myCarousel" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myCarousel" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
</div>
然后在CSS中添加以下代码,来将li标签中的圆点改成实心圆:
.carousel-indicators li span.dot {
height: 12px;
width: 12px;
margin: 0 5px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
.carousel-indicators li.active span.dot {
background-color: #fdd100;
}
阅读全文