Prevent Distortion on Divi Gallery Images

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.


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

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

  3. Thank you sooooooo much!!!

  4. Where do you implement these lines of code?


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.