0

How can I make all items inside this Owl carousel have the same height (as the tallest item)?

$(document).ready(function() {
  $('.owl-carousel').owlCarousel({
    items: 4
  });
});
<link href="//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/assets/owl.carousel.min.css" rel="stylesheet" />
<script src="//code.jquery.com/jquery-3.1.0.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.2.1/owl.carousel.min.js"></script>

<div class="owl-carousel owl-theme">
  <div><img src="http://placehold.it/350x150"></div>
  <div><img src="http://placehold.it/350x100"></div>
  <div><img src="http://placehold.it/350x150"></div>
  <div><img src="http://placehold.it/350x150"></div>
  <div><img src="http://placehold.it/350x150"></div>
  <div><img src="http://placehold.it/350x150"></div>
  <div><img src="http://placehold.it/350x150"></div>
</div>

View on JS Bin

Taku
  • 31,927
  • 11
  • 74
  • 85
Tyler Bean
  • 417
  • 1
  • 4
  • 14
  • Possible duplicate of [Image slider: maintaining equal height for all images while keeping slider responsive](http://stackoverflow.com/questions/21574698/image-slider-maintaining-equal-height-for-all-images-while-keeping-slider-respo) – showdev May 18 '17 at 20:23

1 Answers1

-2

.image{
width:100%;
height:500px
}
 
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>


<div class="container">
  <div id="myCarousel" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="http://www.gettyimages.com/gi-resources/images/frontdoor/creative/PanoramicImagesRM/FD_image.jpg" alt="" class="image" >
      </div>

      <div class="item">
        <img src="http://i.dailymail.co.uk/i/pix/2016/09/13/14/384A98B300000578-0-image-a-63_1473774825844.jpg" alt=""  class="image">
      </div>
    
      <div class="item">
        <img src="https://s-media-cache-ak0.pinimg.com/736x/b1/7c/d0/b17cd0554537ceb0e816537bfcae09eb.jpg" alt=""  class="image">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>
</div>
Anoop Nockson
  • 272
  • 3
  • 2
  • The result is not what I want. Your images' height are still different.And you fixed the image height to 500px? Then I am afraid the ratio is distorted, Thanks for your efforts anyways. – Tyler Bean May 18 '17 at 15:10
  • you need to apply same proportioned images (in height and width) for better quality other wise it seems to be distorted. i put height 500 as an example only – Anoop Nockson May 20 '17 at 07:32