I am trying to align multiple images horizontally and vertically inside a WordPress gallery. I want to have a grid of three images in a row, each of which is aligned in the middle.
Here is the structure:
<div class="gallery">
<dl>
<dt><img src="#" /></dt>
</dl>
<dl>
<dt><img src="#" /></dt>
</dl>
<dl>
<dt><img src="#" /></dt>
</dl>
<dl>
<dt><img src="#" /></dt>
</dl>
</div>
And what I still have in CSS:
.gallery {
display: table;
width: 100%;
height: 100%;
}
dl {
display: table-cell;
text-align: center;
vertical-align: middle;
}
Centering still works. But that makes a lot of columns as there are images. What I want is a new line after every third image.
Here is the jsfiddle of what I have done so far.
Thanks for any help!
source
share