0Wordpress LogoVertically center images in default wordpress gallery

I could­n’t believe a google search did­n’t already turn up the answer for this — it’s crazy that you can­’t just ver­tic­ally-cen­ter the images in a word­press simple image gal­lery. After much faff­ing with CSS I found a simple answer

By default word­press image gal­lerys are giv­en a class ‘gal­lery’ and all that was needed was to apply some flexbox CSS to this gal­lery. For older browsers that don’t sup­port flexbox they will just fall back to the non ver­tic­ally centered gal­lery which isn’t the end of the world.

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

And that’s it! It works with cap­tions both on and off and does­n’t care how many columns or rows there are in your gallery.

Leave a Reply