In this tutorial you will learn how to create carousels with Bootstrap.
Creating Carousels with Bootstrap
The carousel also known as slideshow or image slider is some of the best way of showcasing the huge amount of contents within a small space on the web pages. It is a dynamic presentation of contents where text and images are made visible or accessible to the user by cycling through several items.
The following example will show you how to build a simple carousel or slideshow with previous/next controls and indicators using the Bootstrap carousel plugin.
Example
<div id="myCarousel" class="carousel slide" data-bs-ride="carousel">
<!-- Carousel indicators -->
<ol class="carousel-indicators">
<li data-bs-target="#myCarousel" data-bs-slide-to="0" class="active"></li>
<li data-bs-target="#myCarousel" data-bs-slide-to="1"></li>
<li data-bs-target="#myCarousel" data-bs-slide-to="2"></li>
</ol>
<!-- Wrapper for carousel items -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/slide1.png" class="d-block w-100" alt="Slide 1">
</div>
<div class="carousel-item">
<img src="images/slide2.png" class="d-block w-100" alt="Slide 2">
</div>
<div class="carousel-item">
<img src="images/slide3.png" class="d-block w-100" alt="Slide 3">
</div>
</div>
<!-- Carousel controls -->
<a class="carousel-control-prev" href="#myCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#myCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
— The output of the above example will look something like this:
