I've been facing some challenges with creating a responsive image gallery. Despite using CSS and Bootstrap, I haven't had success with implementing it using the img tag or as a background.
My goal is to achieve something similar to this:
An image grid without warping or overlapping images
Even when resizing the browser window, I want the image aspect ratio to remain constant, only changing in size. As the window shrinks, I'd like two images per row, which can be achieved with col-lg-4 col-md-6
.
Additionally, I would prefer to use the img tag for this as it would make it easier to create a hover effect transitioning from one image to another.
This is the HTML snippet I am currently working with:
<div class="item " data-categoryid="2">
<div class="item-image">
<div class="img-bg" style="background: url("http://laravel.dev/images/bon2.jpg"); display: none;">
</div>
<div class="img-bg" style="background: url("http://laravel.dev/images/bon.jpg");"></div>
</div>
<div class="item-name">Some name</div>
<div class="item-price">price €</div>
<div class="item-button">
<a href="#" class="btn btn-primary">Button.</a>
</div>
</div>