Class Aligncenter image

Hello,

I assigned the class aligncenter to the images I want to center:

.aligncenter { 
  display:block; 
  margin-left: auto;
  margin-right: auto;
}

The problem is that this class doesn’t work correcly, especially with the shadows (see below how it looks like, with the white space on the right side). How can I change the code to make it work?

Thanks,
Antoine

Hi @Lecoqdigital,

Thanks for reaching out.

It will only allow you to align it to the center if there is any defined width. Please try any of these

.aligncenter { 
  display:block; 
  max-width: 400px; /* define the width */
  margin-left: auto;
  margin-right: auto;
}
.aligncenter { 
  display:inline-block; /* inline block will inherit the width */
  margin-left: auto;
  margin-right: auto;
}
.aligncenter img{ /* the image itself has its own width, perhaps selecting the actual img will work instead of the exact class */
  display:block; 
  margin-left: auto;
  margin-right: auto;
}

Thanks!

Thank you. I used the second one (I tested the other one as well…), but it doesn’t center the image. Any idea how to make it works?

.aligncenter { 
  display:inline-block; /* inline block will inherit the width */
  margin-left: auto;
  margin-right: auto;
}

Hi Antoine,

There are several domains in your licenses page so I am not sure which one is the site in question.

For us to be able to provide a more accurate suggestion, please provide us with the site URL so that we can double check it.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.