How to center image using jqmobile

Hi, I use this code snippet to center the image in jQuery mobile, it centers the image in the iphone simulator, but when I test it on the iphone, it doesn't exactly center (the center itself, but not quite), but tends to the left.

<div data-role="content" data-theme="a"> <div id="logo_image"> <img src="images/logo.png" alt="Image Header" > </div> </div> 

and css -

 #logo_image { text-align: center; margin-left:0 auto; margin-right:0 auto; } 

Thanks in advance...

+4
source share
3 answers

just try margin: 0 auto instead of left and right margins. after that you can set the upper and lower margins. Congratulated

+5
source

Try adding diplay: block to your image, this should be correct.

+2
source

These other answers are partially correct, but in order for the margin: 0 auto properties to work, I believe that you also need to specify the width for your element.

Something like that:

 #logo_image { text-align: center; margin-left:0 auto; margin-right:0 auto; width: 80%; } 
+2
source

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


All Articles