Solution 1 :

Missing active class in the carousel-item. Add in the active class and it will work

<div class="carousel-item active"> <!-- Add in active class -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>


<div class="carousel slide" id="cservices" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active"> <!-- Add in active class -->
      <img class="d-block w-100" src="https://picsum.photos/id/100/400/300" alt="first slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://picsum.photos/id/200/400/300" alt="second slide">
    </div>
    <div class="caruousel-item">
      <img class="d-block w-100" src="https://picsum.photos/id/900/400/300" alt="third slide">
    </div>

    <a class="carousel-control-prev" href="#cservices" role="button" data-slide="prev">
      <span class="carousel-control-prev-icon" aria-hidden="true"></span>
      <span class="sr-only">next</span>
    </a>
    <a class="carousel-control-next" href="#cservices" role="button" data-slide="next">
      <span class="carousel-control-next-icon" aria-hidden="true"></span>
      <span class="sr-only">previous</span>
    </a>
  </div>
</div>

Problem :

Here’s my code. I’m trying to get an image carousel with button controls but I can’t get the images to transition. The buttons aren’t working a all.

 <div class="carousel slide" id="cservices" data-ride="carousel">
          <div class="carousel-inner">
              <div class="carousel-item">
                  <img class="d-block w-100" src="img/doctor.jpg" alt="first slide">
              </div>
              <div class="carousel-item">
                  <img class="d-block w-100" src="img/nurse.jpg" alt="second slide">
              </div>
              <div class="caruousel-item">
                  <img class="d-block w-100" src="img/forklift.jpg" alt="third slide">
              </div>

              <a class="carousel-control-prev" href="#cservices" role="button" data-slide="prev">
                  <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                    <span class="sr-only">next</span>
            </a>
            <a class="carousel-control-next" href="#cservices" role="button" data-slide="next">
                  <span class="carousel-control-next-icon" aria-hidden="true"></span>
                    <span class="sr-only">previous</span>
                </a>
          </div>
      </div>

I don’t currently have any css applied to it. I’ve compared it to the bootstrap example and I can’t figure out whats wrong.

Comments

Comment posted by Marvin

Can you give more information on what your goal is?

Comment posted by jjfaress

I tried using the active class. All it did was place the active image above the non-functioning carousel.

Comment posted by yinsweet

@jjfaress did you include the jquery-3.5.1.slim.min.js, popper.min.js and bootstrap.min.js path? All I did was just adding the

By

Leave a Reply

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