How to change Image of Bootstrap Carousel on Mobile View?

/*Carousel CSS for Mobile View*/
@media (max-width: 425px){
  #banner-one img{
    background-image: url("/images/mobile_banner1.jpg") !important;
  }
  
  #banner-two img{
    background-image: url("/images/mobile_banner2.jpg") !important;
  }
  
  #banner-three img{
    background-image: url("/images/mobile_banner3.jpg") !important;
  }
  
  #banner-four img{
    background-image: url("/images/mobile_banner4.jpg") !important;
  }
}
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div id="banner-one" class="carousel-item active">
      <img class="d-block w-100" src="/images/banner-one.jpg" alt="First slide">
    </div>
    <div id="banner-two" class="carousel-item">
      <img class="d-block w-100" src="/images/banner-two.jpg" alt="Second slide">
    </div>
    <div id="banner-three" class="carousel-item">
      <img class="d-block w-100" src="/images/banner-three.jpg" alt="Third slide">
    </div>
    <div id="banner-four" class="carousel-item">
      <img class="d-block w-100" src="/images/banner-four.jpg" alt="Third slide">
    </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>

I have a Bootstrap Carousel in my project it works perfect in each and every view. But I want to change the carousel images of every slide in the Mobile View. I have tried everything but failed. Please help the needful. Thanks in advance 🙂

40 thoughts on “How to change Image of Bootstrap Carousel on Mobile View?”

Leave a Comment