Text-align does not work on img tag

Take a look at my fiddle: http://jsfiddle.net/jVsQY/

As you can see, I use text-align: center in the image tag, with the class, and it does not show any results.

I tried to use display: inline-block and so, but it didn't help.

+4
source share
2 answers

To center the alignment of the image, you need to do something like this:

 <div style="text-align:center;"><img src="image.jpg" /></div> 

Or like this:

 <img src="image.jpg" style="display:block; margin:auto; "/> 
+12
source

If you use this CSS, you will get the image in the center

 .center { display: block; margin-left: auto; margin-right: auto;} 
+1
source

Source: https://habr.com/ru/post/1393661/


All Articles