I’m trying to layout images vertically aligned bottom (see picture below) in a responsive layout with images of unknown heights.
The images are scaled to fit the width of the column, but the heights vary and I cannot find out what it is in advance.

Unfortunately at the moment the closest I have managed to get is this

I’d really like to avoid using javascript if possible, because the number of columns will change depending on the screen width using media queries – which will make the javascript more complex.
The CSS I am using at the moment is
#catalogue-items {
@include clearfix;
margin: 40px 0;
.catalogue-item {
width: 20%;
float: left;
margin-left: 4%;
@include box-sizing(border-box);
margin-bottom: 20px;
img {
width: 100%;
}
p {
font-family: sans-serif;
font-size: 0.8em;
padding: 0.5em;
}
&:nth-child(4n + 1) {
clear:left;
}
}
}
With the nth-child selector changing using media queries.
Is there any way to do this?
I would solve it using
display: inline-blockHTML:
CSS:
See Fiddle