Search code examples
htmlcsscarousel

Carousel Height Problem, The default Carousel height is too large


I am trying to shorten the height to 500px from 1000px. Since this is my first time including bootstrap I have difficulty understanding which css class affects the carousel. If you can give me tips or a guide it would be much appreciated

Code


Solution

  • This is set to a max-width of 500px.

    Here it is in a Codepen, too.

    $('.carousel').carousel({
      interval: 2000
    })
    .carousel-item {
      max-height: 500px;
    }
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/js/bootstrap.bundle.min.js"></script>
    
    
    
    <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 class="d-block w-100" src="http://placeimg.com/1920/1080/1" alt="First slide">
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="http://placeimg.com/1920/1080/2" alt="Second slide">
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="http://placeimg.com/1920/1080/3" alt="Third slide">
        </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>