I'm in the midst of creating a gallery. I have rows of thumbnail images where each row is its own div
, and there are five thumbnails to a row. The problem is, the heights of these thumbnails are neither uniform nor predictable. I have given the thumbnails a width of 10.25rem
in order to keep their widths predictable while maintaining their proportional heights. Unfortunately, this has resulted in the horizontally-aligned images to have varying degrees of whitespace above them, and the result is kind of ugly. My current code, just so we're all on the same page at this point:
Relevant CSS:
#gallery {
margin-top: 0.85em;
}
.gallery-row {
margin-top: 0.25em;
}
.gallery-thumb {
margin: 0 0.25em;
width: 10.250rem;
border: 1px solid #c70f36;
border-radius: 4px;
}
Relevant HTML/Twig:
<div id="gallery">
<div class="gallery-row">
{% for image in images %}
{% if loop.index0 % 5 == 0 %}
</div><div class="gallery-row">
{% endif %}
<a href="{{ asset('uploads/gallery/' ~ image.filename) }}" data-lightbox="gallery"><img src="{{ asset('uploads/gallery/' ~ image.filename) }}" class="gallery-thumb"></a>
{% endfor %}
</div>
</div>
What I'd like to do is vertically align all the images to the middle of each gallery-row
. Since the row's height is dependent on the tallest thumbnail, they'd fill the row and the shorter thumbnails would be in the middle rather than the bottom. Only problem is that I'm not sure how to do it. I've tried the various suggestions listed here, but they haven't worked. All I get are my images stacked on top of one another, completely outside of the normal document flow.