I am trying to implement a carousel using Bootstrap, but I am facing an issue with displaying images of different dimensions. I want the images to maintain a fixed ratio within the carousel, but all my attempts with CSS have failed so far.
CSS
.carousel .item > img {
position: absolute;
top: 0;
left: 0;
min-width: 100%;
height: 702px;
max-width: none;
}
Here is the HTML code:
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item">
<img src="image1.jpg"/>
</div>
<div class="item">
<img src="image2.jpg"/>
</div>
</div>
</div>
Do you think I should explore other carousel options that maintain image ratios or is there a workaround for this?
EDIT 1 :
.carousel .item > img {
max-width: 100%;
height: 100%;
width: auto;
text-align: center;
margin: 0 auto;
}