- This topic is empty.
-
AuthorPosts
-
September 17, 2013 at 1:09 pm #150348
farzadina
ParticipantThere is a button in a div, surrounded by
<section>
:<div id="body"> <section> <div class="area"> <button>Hello!</button> </div> </section> </div>
The
#body
, its<section>
have a fixed width and the.area
have a 50px padding:#body{ width:600px; margin:0 auto; background:#eee; } section{ width:300px; margin:0 auto; background:#FFF; } .area{ padding:50px; } button { display: block; margin: 0 auto; }
Everything is done in my monitor, and the button is centered perfectly. But on ipad it shifts to left:
You can see this case in action: http://jsfiddle.net/c2HLe
September 17, 2013 at 1:21 pm #150350Paulie_D
MemberWe’d probably need to test an actual live link & not a JSFiddle just to make sure there isn’t anything else going on.
September 17, 2013 at 1:46 pm #150352farzadina
ParticipantHere is an actual live link:
http://baghbagho.com/kingschool/
See the Photo Gallery’s show me more buttonSeptember 17, 2013 at 2:12 pm #150355Paulie_D
MemberI can’t see any reason for it specifically.
All the section widths (1000px) should be fine on an iPad (in landscape mode, I think) and you have the correct meta for device width.
Does it happen in both portrait and landscape mode?
It’s almost as though the centering by margin isn’t taking effect.
I’m pretty stumped…about the only think i can think of, and I have no idea why this should make a difference, is to take it out of the gallery div but leave it inside the section.
You would have to update the css selector from
.gallery button
to.content button
but I would be curious to see if this changes anything.Something to do with the inline-block images perhaps?
September 18, 2013 at 12:48 am #150434farzadina
ParticipantDoes it happen in both portrait and landscape mode?
Yes, both.
take it out of the gallery div but leave it inside the section.
I made this, but the result didn’t changed.I made a better example, it’s so simple:
http://jsfiddle.net/c2HLe/9/
See the result:
September 18, 2013 at 1:13 am #150439farzadina
ParticipantI used this method to solve the problem:
http://stackoverflow.com/questions/18866532/margin-centered-button-shifts-to-left-in-ipadI added a
.button-wrapper
as parent of my button and gave ittext-align:center
style, then added adisplay:inline-block
to the button, so it centered in both monitor & ipad. -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.