Carousel
A slideshow component for cycling through elements, images or slides of text.
Slides only
A carousel with slides only. Note the presence of the
.d-block
and
.w-100
on carousel images to
prevent browser default image alignment.
<!-- Slides only carousel -->
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
</div>
</div>
</div>
With controls
Adding in the previous and next controls
<!-- Carousel with controls -->
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
</div>
</div>
<a
class="carousel-control-prev"
href="#carouselExampleControls"
role="button"
data-slide="prev"
>
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a
class="carousel-control-next"
href="#carouselExampleControls"
role="button"
data-slide="next"
>
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
With indicators
You can also add the indicators to the carousel, alongside the controls, too.
<!-- Carousel with indicators -->
<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="carousel-item active">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
</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">Previous</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">Next</span>
</a>
</div>
With captions
Add captions to your slides easily with the
.carousel-caption
element within
any .carousel-item
.
<!-- Carousel with captions -->
<div id="carouselExampleCaptions" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li
data-target="#carouselExampleCaptions"
data-slide-to="0"
class="active"
></li>
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
<div class="carousel-caption d-none d-md-block">
<h5>First slide label</h5>
<p>Nulla vitae elit libero, a pharetra augue mollis interdum.</p>
</div>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
<div class="carousel-caption d-none d-md-block">
<h5>Second slide label</h5>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
<div class="carousel-caption d-none d-md-block">
<h5>Third slide label</h5>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur.</p>
</div>
</div>
</div>
<a
class="carousel-control-prev"
href="#carouselExampleCaptions"
role="button"
data-slide="prev"
>
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a
class="carousel-control-next"
href="#carouselExampleCaptions"
role="button"
data-slide="next"
>
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Crossfade
Add .carousel-fade
to your carousel
to animate slides with a fade transition instead of a slide.
<!-- Carousel with crossfade -->
<div
id="carouselExampleFade"
class="carousel slide carousel-fade"
data-ride="carousel"
>
<div class="carousel-inner">
<div class="carousel-item active">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
</div>
</div>
<a
class="carousel-control-prev"
href="#carouselExampleFade"
role="button"
data-slide="prev"
>
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a
class="carousel-control-next"
href="#carouselExampleFade"
role="button"
data-slide="next"
>
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Individual slide interval
Add data-interval=""
to a
.carousel-item
to change the amount
of time to delay between automatically cycling to the next item.
<!-- Carousel with individual slide interval -->
<div id="carouselExampleInterval" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" data-interval="10000">
<img
src="../assets/img/Pic1-800x250.jpg"
class="d-block w-100"
alt="A placeholder image1"
/>
</div>
<div class="carousel-item" data-interval="2000">
<img
src="../assets/img/Pic2-800x250.jpg"
class="d-block w-100"
alt="A placeholder image2"
/>
</div>
<div class="carousel-item">
<img
src="../assets/img/Pic3-800x250.jpg"
class="d-block w-100"
alt="A placeholder image3"
/>
</div>
</div>
<a
class="carousel-control-prev"
href="#carouselExampleInterval"
role="button"
data-slide="prev"
>
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a
class="carousel-control-next"
href="#carouselExampleInterval"
role="button"
data-slide="next"
>
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>