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.

This post may contain referral links which may earn a commission for this site

Divi Booster

Hundreds of new features for Divi
in one easy-to-use plugin


  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

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