How can I correctly center an image using custom HTML?

How can I correctly center an image using custom HTML?

lifehackaus
Tourist
6 0 2

Hi I've used the following code.

<div style="text-align:center">
<img src="https://cdn.shopify.com/s/files/1/666/666/9139/files/aaa.png?v=1587954210">
</div>

 

But still doesn't seems to be working. Any suggestions please. Thank You.
Capture.PNG

Replies 10 (10)

balmcraft
Visitor
1 0 11

I had this same problem and I fixed it with inline CSS that sets the display type to a block inside the <img> element. The "text-align: center" solution that is commonly suggested doesn't apply to images because... well, it's for text alignment rather than images.

 

<img style="display: block; margin-left: auto; margin-right: auto; width: 50%" src=(whatever your actual source is)>

 

You can change how large the image is with the "width" property.

 

GogoGogo
Visitor
2 0 1

Yes! It works: img center + desired size. Thanks!

Magdiel
Tourist
3 0 1

A onde posso mudar isso não estou conseguindo!

 

Family_35
Tourist
10 0 3

Olá. Você conseguiu resolver?

KauanSales
Shopify Partner
2 0 2

Eu não sei como fazer, onde que devo fazer, poderia ensinar?

 

Tudo
Visitor
1 0 1

God thanks, it worked for me !

MCOFA
Excursionist
30 0 12

THANK YOU for this!

ISparks099
Tourist
5 0 3

Worked great, thank you!

Family_35
Tourist
10 0 3

Thank you so much!!!

AlexBLB
Visitor
1 0 0

Hey sorry for asking this 4 years later but where should I put it? I put it in a custom CSS inside a image with text as well as a custom liquid block but it still doesn't work somehow