I want to display a grid of images. Each row (contained in a div) spans the entire width of the screen and each image occupies one third of the width of the row. I have achieved this with the following CSS.
img {
max-width: 33.33%;
}
The issue however is that because the images are of varying heights, each row has the height of the tallest image in the row. As a result there are vertical gaps in between the images of the different rows. I would like to make it so that if there is vertical space above an image it moves itself up to fill that space and so on with the images below it to give this effect.
Currently I am working on doing this with JavaScript, altering the relative position of each image to fill the space above with some success. But I believe there is a pure CSS way to achieve this.