css - Bootstrap carousel different height images cause bouncing -
i've been using bootstrap 3.3.7v's carousel class , has been straightforward far, 1 problem i've had images of different heights cause divs under bounce , images overflowing out carousel. have googled , followed of answers in stackoverflow, not solved problem. request briefly explain issue.
<div class="col-md-6" style="padding:0px;"> <div id="carousel-example-generic" class="carousel slide" data- ride="carousel"> <!-- indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- wrapper slides --> <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="images/slider/1.jpg" alt="blue"> </div> <div class="item"> <img src="images/slider/2.jpg" alt="purple"> </div> <div class="item"> <img src="images/slider/3.jpg" alt="red"> </div> <div class="item"> <img src="images/slider/4.jpg" alt="red"> </div> <div class="item"> <img src="images/slider/5.jpg" alt="red"> </div> </div> <!-- controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">next</span> </a> </div> </div>
you can set css of images cover carousel , set maximum height on carousel.
img{ object-fit:cover; object-position:center; } .item{ width:100% height:100% } .carousel{ width:100% min-height:500px; max-height:860px; }
i'm not sure bootstrap 3 know bs4 has .img-fluid class can fit images too.
Comments
Post a Comment