Hi, I'm new to "programming" and seeking assistance here on stackoverflow.
I'm encountering a slight issue trying to fit an image inside my grid layout.
For example, when I have an image with a specific size, it works fine. However, if the image is slightly larger or in a different format (such as 16:9 instead of 9:16), it doesn't display properly within the grid - neither fitting fully nor getting cropped.
I am using identical HTML code and CSS for both grids; the only variance is in the image itself. My setup includes Bootstrap along with some custom CSS.
The CSS Styling
.grid {
position: relative;
clear: both;
margin: 0 auto;
max-width: 1000px;
list-style: none;
text-align: center;
}
.grid figure {
position: relative;
overflow: hidden;
margin: 10px 0;
height: auto;
text-align: center;
cursor: pointer;
}
.grid figure img {
position: relative;
display: block;
min-height: 100%;
width: 100%;
opacity: 0.8;
}
<div class="gallery">
<div class="container">
<div class="gallery-grids">
<div class="col-md-4 gallery-grid">
<div class="grid">
<figure class="effect-roxy">
<a class="example-image-link" href="/images/fotos/gal1.jpg" data-lightbox="example-set" data-title="In lacinia pharetra ipsum vel dapibus. Ut vitae tristique nisi, mattis pellentesque elit. Proin mollis sed nisi ac sodales.">
<img src="/images/fotos/gal1.jpg" alt="" />
<figcaption>
<h3>Maecenas <span>lacus</span></h3>
<p> Aenean fermentum nisl ac imperdiet commodo</p>
</figcaption>
</a>
</figure>
</div>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>