bootstrap 4 - carousel, img-fluid

portrait images and landscape images

by Phil Brown

HTML

<script src="//code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="//stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="img-fluid" src="https://images.pexels.com/photos/132037/pexels-photo-132037.jpeg" alt="First slide">
      <div class="carousel-caption">
        <h3>Image #1</h3>
      </div>
    </div>
    <div class="carousel-item">
      <img class="img-fluid" src="https://thumbs.dreamstime.com/b/dead-tree-tall-portrait-view-blue-sky-background-57002950.jpg" alt="Second slide">
      <div class="carousel-caption">
        <h3>Image #2</h3>
      </div>
    </div>
    <div class="carousel-item">
      <img class="img-fluid" src="https://images.pexels.com/photos/414171/pexels-photo-414171.jpeg" alt="Third slide">
      <div class="carousel-caption">
        <h3>Image #3</h3>
      </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>

CSS

#carouselExampleControls {
  height: 350px;
  text-align: center;
  background: gray;
}

.img-fluid {
  max-height: 350px;
}
.carousel-caption {
  position: static;
  background: grey; /* You'll probably want to set this */
}