I am dealing with a carousel that has fixed dimensions (e.g., width=800px, height=450px), but the images I want to display in it have varying aspect ratios (16 : 9, 16:10, 1:1, etc.) and are larger than the carousel itself. I am attempting to resize all the images to fit within the confines of my carousel.
Here is the code for the carousel:
<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="carousel-img" src="{{ last_post.image.url }}"
alt="First slide">
</div>
<div class="carousel-item">
<img class="carousel-img"
src="{{ second_last_post.image.url }}" alt="Second slide">
</div>
<div class="carousel-item">
<img class="carousel-img" src="{{ third_last_post.image.url }}"
alt="Third slide">
</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:
.carousel-inner {
height: 450px;
width: 800px;
}
Is there a way to adjust the image sizes to properly fit inside the carousel?