Reputation: 772
Hi i am using this piece of code to center image in jquery mobile, it centers the image in iphone simulator but when i check it on iphone, it did not exactly centers (centers itself but not exactly) itself but tends towards left.
<div data-role="content" data-theme="a">
<div id="logo_image">
<img src="images/logo.png" alt="Image Header" >
</div>
</div>
and the css is
#logo_image {
text-align: center;
margin-left:0 auto;
margin-right:0 auto;
}
Thanks in advance...
Upvotes: 4
Views: 13050
Reputation: 13115
These other answers are partially correct, but in order for the margin: 0 auto
properties to work, I believe you also have to specify a width
for your element.
Something like this:
#logo_image {
text-align: center;
margin-left:0 auto;
margin-right:0 auto;
width: 80%;
}
Upvotes: 2
Reputation: 557
just try margin: 0 auto
instead of left & right margin. you'll be able to set the top and bottom margin afterwards.
greets
Upvotes: 5