The carousel is a slideshow for cycling through a series of content. Read the Official Bootstrap Documentation for a full list of instructions and other options.
Here’s a carousel with slides only. Note the presence of the .d-block and .w-100 on carousel images to prevent browser default image alignment.
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://via.placeholder.com/500x281" class="d-block w-100" alt="...">
</div>
<!-- more items goes here -->
</div>
</div>
Adding in the previous and next controls.
<div id="carouselExample2" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">...</div>
<a class="carousel-control-prev" href="#carouselExample2" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"><i data-feather="chevron-left"></i></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExample2" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"><i data-feather="chevron-right"></i></span>
<span class="sr-only">Next</span>
</a>
</div>
You can also add the indicators to the carousel, alongside the controls, too.
<div id="carouselExample3" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExample3" data-slide-to="0" class="active"></li>
<li data-target="#carouselExample3" data-slide-to="1"></li>
<li data-target="#carouselExample3" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">...</div>
<a class="carousel-control-prev" href="#carouselExample3" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"><i data-feather="chevron-left"></i></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExample3" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"><i data-feather="chevron-right"></i></span>
<span class="sr-only">Next</span>
</a>
</div>
Add captions to your slides easily with the .carousel-caption
element within any .carousel-item
.
<div class="carousel-item">
<img src="..." alt="...">
<div class="carousel-caption d-none d-md-block">
<h5>...</h5>
<p>...</p>
</div>
</div>
Add fade transition to your carousel to animate slides with a fade transition instead of a slide.
<div id="carouselExample" class="carousel slide carousel-fade" data-ride="carousel">...</div>