Prevent Distortion on Divi Gallery Images

Written by Dan Mossop

The Divi Theme gallery module has a grid view which shows thumbnails of the images in the gallery. Sometimes the thumbnails will appear distorted, as small images are stretched to fill the thumbnail area. To prevent the image stretching, we can use the following CSS:

.et_pb_gallery_image img { 
    width: auto !important;
    height: auto !important;
    position: relative;
    left: 50% !important;
    -webkit-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    transform: translateX(-50%);
}

This removes the minimum height and width setting which was causing the stretching, and centers the image in the thumbnail area.

Discover Divi Gallery Booster

Divi Gallery Booster adds all the missing options you need to style your Divi gallery modules with ease. Save time and impress your site visitors and clients with breathtaking galleries.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

5 Comments

  1. Thank you as I use divi theme for most clients.

    Reply
  2. Ohmygod. THANK YOU. I was pulling my hair out. It was not pretty.

    Reply
  3. Thank you sooooooo much!!!

    Reply
  4. Where do you implement these lines of code?

    Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.