0Wordpress LogoVertically center images in default wordpress gallery

I couldn’t believe a google search didn’t already turn up the answer for this – it’s crazy that you can’t just vertically-center the images in a wordpress simple image gallery. After much faffing with CSS I found a simple answer

By default wordpress image gallerys are given a class ‘gallery’ and all that was needed was to apply some flexbox CSS to this gallery. For older browsers that don’t support flexbox they will just fall back to the non vertically centered gallery which isn’t the end of the world.

.gallery
{
display: flex;
flex-flow: wrap;
align-items: center;
}

And that’s it! It works with captions both on and off and doesn’t care how many columns or rows there are in your gallery.

Found this useful? Please do let us know by dropping a comment below. If you would like to subscribe please use the subscribe link on the menu at the top right. You can also share this with your friends by using the social links below. Cheers.

Leave a Reply