Home > database >  Why does the carousel dissappear after the last last slide?
Why does the carousel dissappear after the last last slide?

Time:09-29

I'm practicing bootstrap and when I click after the last slide, the whole carousel disappears. Even on the first slide, when I click the left arrow to go to the last slide the whole thing still disappears.

<!-- Team Pictures Carousel -->
    <div class="row bg-dark rounded-bottom">
      <div class="col">
        <!-- Carousel Component -->
        <div id="carouselExampleControls" class="carousel slide w-50 mx-auto" data-ride="carousel">
          <div class="carousel-inner">
            <div class="carousel-item active">
              <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/brian.png" class="d-block w-100" alt="some guy named brian">
              <div class="carousel-caption bg-dark rounded-pill py-0">
                <p class="text-center font-weight-bold mb-0">CEO: <span class="font-weight-light">Brian M.</span></p>
              </div>
            </div>
            <div class="carousel-item">
              <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/andy.png" class="d-block w-100" alt="another dude named andy">
              <div class="carousel-caption bg-dark rounded-pill py-0">
                <p class="text-center font-weight-bold mb-0">CFO: <span class="font-weight-light"> Andy C.</span></p>
              </div>
            </div>
            <div class="carousel-item">
              <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/angela.png" class="d-block w-100" alt="angela?">
              <div class="carousel-caption bg-dark rounded-pill py-0">
                <p class="text-center font-weight-bold mb-0">COO: <span class="font-weight-light">Angela W.</span></p>
              </div>
            <div class="carousel-item">
              <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/amie.png" class="d-block w-100" alt="amie or amy?">
              <div class="carousel-caption bg-dark rounded-pill py-0">
                <p class="text-center font-weight-bold mb-0">CTO: <span class="font-weight-light">Amie S.</span></p>
              </div>
            </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>
      </div>
    </div>
    
  </div>

CodePudding user response:

The item with "COO" was missing the close tag and because of that the "carousel-inner" div was closing in the wrong place. This worked fine:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1 K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2 l" 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/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<div class="row bg-dark rounded-bottom">
  <div class="col">
    <!-- Carousel Component -->
    <div id="carouselExampleControls" class="carousel slide w-50 mx-auto" data-ride="carousel">
      <div class="carousel-inner">
        <div class="carousel-item active">
          <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/brian.png" class="d-block w-100" alt="some guy named brian">
          <div class="carousel-caption bg-dark rounded-pill py-0">
            <p class="text-center font-weight-bold mb-0">CEO: <span class="font-weight-light">Brian M.</span></p>
          </div>
        </div>
        <div class="carousel-item">
          <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/andy.png" class="d-block w-100" alt="another dude named andy">
          <div class="carousel-caption bg-dark rounded-pill py-0">
            <p class="text-center font-weight-bold mb-0">CFO: <span class="font-weight-light"> Andy C.</span></p>
          </div>
        </div>
        <div class="carousel-item">
          <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/angela.png" class="d-block w-100" alt="angela?">
          <div class="carousel-caption bg-dark rounded-pill py-0">
            <p class="text-center font-weight-bold mb-0">COO: <span class="font-weight-light">Angela W.</span></p>
          </div>
        </div>
        <div class="carousel-item">
          <img src="https://content.codecademy.com/courses/learn-bootstrap-4/adhoc/amie.png" class="d-block w-100" alt="amie or amy?">
          <div class="carousel-caption bg-dark rounded-pill py-0">
            <p class="text-center font-weight-bold mb-0">CTO: <span class="font-weight-light">Amie S.</span></p>
          </div>
        </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>
  </div>
</div>

  • Related