Bootstrap Carousel Slider with thumbnails

Bootstrap provides a carousel with some options. This post is to create a responsive Bootstrap Carousel Slider with thumbnails.

Final output:


1. Let’s start with the Bootstrap 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="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </div>
    <div class="carousel-item">
      <img src="..." class="d-block w-100" alt="...">
    </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>

2. Add your images to the carousel. Also, check for the same number of carousel indicator list items.

<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>
        <li data-target="#carouselExampleIndicators" data-slide-to="3"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="4"></li>
    </ol>
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg"
                class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100">
        </div>
    </div>
</div>

Output:

3. Now, just add the images to the carousel indicators list as well.

<ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg" class="d-block w-100">
    </li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="3"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="4"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100"></li>
</ol>

Output:

4. There you go! Thumbnails. But, they don’t look so good. Let’s style them.

  .carousel-indicators li {
    width: 200px;
    height: 100%;
    opacity: 0.8;
  }

Output:

5. To place the thumbnails at the bottom, move the carousel indicators list out of the carousel div. The default position of carousel-indicators set by Bootstrap is absolute. Change it to static. I removed the next-previous controls as well.

<div id="carouselExampleIndicators5" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg"
                class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100">
        </div>
    </div>
</div>
<ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators5" data-slide-to="0" class="active"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg" class="d-block w-100">
    </li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="1"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="2"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="3"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="4"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100"></li>
</ol>

.carousel-indicators {
    position: static;
}

Output:


Final Output Code for Bootstrap carousel slider with thumbnails

HTML

<div id="carouselExampleIndicators5" class="carousel slide" data-ride="carousel">
    <div class="carousel-inner">
        <div class="carousel-item active">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg"
                class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100">
        </div>
        <div class="carousel-item">
            <img src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100">
        </div>
    </div>
</div>
<ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators5" data-slide-to="0" class="active"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-1-scaled.jpg" class="d-block w-100">
    </li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="1"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-2.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="2"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-3.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="3"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-4.jpg" class="d-block w-100"></li>
    <li data-target="#carouselExampleIndicators5" data-slide-to="4"><img
            src="https://codingyaar.com/wp-content/uploads/bootstrap-carousel-slide-5.jpg" class="d-block w-100"></li>
</ol>

CSS

.carousel-indicators {
  position: static;
}
.carousel-indicators li {
  width: 300px;
  height: 100%;
  opacity: 0.8;
}

Leave a Reply

Your email address will not be published. Required fields are marked *