To place carousel indicators in Bootstrap 4, you can use the ol
element with a class of carousel-indicators
. Inside the ol
, you should create li
elements for each slide in the carousel, giving each li
a data-target
attribute that matches the id
of the corresponding slide.
Here's an example:
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<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>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="slide1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="slide2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="slide3.jpg" alt="Third slide">
</div>
</div>
</div>
In this example, we have a carousel with three slides, and we've created a set of indicators that correspond to each slide. The first li
has a class of active
to indicate that it is the currently active slide.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-03-10 11:00:00 +0000
Seen: 1 times
Last updated: Aug 19 '22