I am trying to make a layout for images in my rails app and I'm having trouble with the alignment.
html
<div class="photos">
<div class="photo-row">
<div class="photo-wrapper">
<a class="fancybox" rel="group" href=""><img class="pending-photo" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" alt=""></a>
</div>
<div class="photo-wrapper">
<a class="fancybox" rel="group" href=""><img class="pending-photo" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" alt=""></a>
</div>
<div class="photo-wrapper">
<a class="fancybox" rel="group" href=""><img class="pending-photo" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" alt=""></a>
</div>
</div>
<div class="photo-row">
<div class="photo-wrapper">
<a class="fancybox" rel="group" href=""><img class="pending-photo" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" alt=""></a>
</div>
<div class="photo-wrapper">
<a class="fancybox" rel="group" href=""><img class="pending-photo" src="http://blog.blogcatalog.com/wp-content/uploads/mario-300x300.jpg" alt=""></a>
</div>
</div>
</div>
css
.photos {
display: flex;
flex-direction: column;
border: 10px solid goldenrod;
}
.photo-row {
border: 5px solid red;
display: flex;
}
.photo-wrapper {
border: 5px solid greenyellow;
margin-right: 20px;
}
.photo-wrapper:last-child {
margin-right: 0;
}
.pending-photo {
width: 100%;
}
I thought flexbox would be the best way to do this. I would like the images to resize on windows resize, that's why I have have width: 100%.
But the problem I run into is that when the last row doesn't have three images they change their size slightly and I want to keep the images the same size. I want all images in all rows to be the same size as images in a full row. All images must be same size always.
I tried removing the rows and just let it be one big flexbox, but was encountering alignment issues with that as well.
If you use instagram find someone with the last row of pics not being full. This is the functionality I want, but can't figure out how they do it.
jsfiddle
https://jsfiddle.net/kk7httso/11/
EDIT:
Actually looks like my question is a duplicate of Flex-box: Align last row to grid. I solved my problem inserting empty elements to fill the row, like the first answer there suggests.