You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

HTML /CSS - Different margins on iPad?

Hi there,


Over the weekend, I've been doing a quick mockup of a website I may get a chance to work on. Typically, everything works fine on Safari for desktop, Chrome, etc., but on iPad, elements seem to get pushed down, especially text.


A second site I'm desinging also has this issue - I can't work out if it's a problem in my code, or a problem with a default CSS file that the iPad has for text, etc.


The mockup is at http://www.jamieshaw.me/other/dsu/index.html.


Any help that could be offered would be great.


Cheers,

Jamie

Posted on Sep 10, 2012 1:53 AM

Reply
13 replies

Sep 10, 2012 8:07 AM in response to jamie.shaw

jamie.shaw wrote:


Is it an iPad (1st Gen) or iPad 2?



I checked it on my iPad1 and my wife's iPad 3 - no difference that I can see. The biggest problem I can see is that huge image that needs to be reduced.


It seems to be an issue with retina displays as Safari on the new 15" MacBook Pro also has an issue.


I didn't look at your code because I can't see anything that is wrong. Can you say specifically which elements are displaying incorrectly? Just because it looks correct doesn't mean it is. A retina display might show that.


It's only a miniscule amount, but text is pushed down and "uncentered" if one has specifically set margins to vertically align objects.


Remember that fonts are different. You aren't ever going to get things to be exactly the same. It is better to use a more flexible design that will accomodate differences in browsers.

Sep 10, 2012 8:09 AM in response to TheClapp81

TheClapp81 wrote:


Hey etresoft, I have a just a couple questions for you (something I'm doing for school). What's the best way to contact you?

It is something specific that I am doing? Go to my website and there are e-mail links not well hidden. If it is more of a general question, it would be better to start your own question here. Someone else may have a much better answer than me.

Sep 10, 2012 8:20 AM in response to etresoft

As for the large image, I'm basically redesiging my Student Union site and using alot of their assets, because their current site is garbage. This is just a bit of fun experimenting with design.


I've taken a few screenshots to highlight the issue; again, it's nothing major, but kind of annoying when time has been spent to vertical align - I'm just a perfectionist 😝
User uploaded file

As seen on my 13" MacBook pro.
User uploaded file

As seen on my iPad (3rd Gen).


The main problem is that all text on the page is pushed down, only by ~10 pixels or so, if that. It's most noticable in the buttons.
Similarly, I also get the same problem with something else that I'm working on. However, my own personal website doesn't have this issue, except in the search box.


If it is an issue in my coding, it'd just be nice to know so I can better my projects in future 🙂

Sep 10, 2012 8:59 AM in response to jamie.shaw

Afer overlaying those two images, I can see what you are talking about.


I think you have too much presentation structure in your code. Each menu item is:


<a class="navlink" href="">

<div class="navicon">

</div>

<div class="navtext">

About

</div>

</a>


All you really need is:

<a class="navlink" href="">About</a>


And you could probably even infer the "navlink" class from the parent.


All those elements provide more opportunities for slight variations. Also, You are using some "*" CSS rules to set relative position on everything. I try hard to do as little as possible. The more of your code there, there greater the chance for a browser to screw it up. Finally, and this is the biggest point, you are specifying VAG Rounded bold for a font. I like that font but it isn't on the iPad. You are going to fall back to a different font with different spacing. Always use iPad fonts.


Also, you have a very slight vertical offset on ":active". I think that should be either removed or accentuated.


PS: I like the ":hover" on your nav items. Can I steal that? Coding is easy, but design is hard.

Sep 10, 2012 9:59 AM in response to etresoft

Thanks for the heads up on the coding; you're right, it would remove some of the soupiness from it.


And yeah, the "*" is something I've only started recently as it became a tendancy of mine to add those styles to the start of every element I specified in CSS. I'll try and go over to remove them and see if it corrects the problem. I also thought the VAG Rounded font could be an issue, as I'm using it natively on my desktop, and as a webfont on iPad - however, a desktop machine without the font, and using Arial on iPad still produced a similar issue.
I think I have actually encountered this issue once before, and I think I managed to combat it using line-spacing or line-height. I think the iPad perhaps has a default CSS file to make it more ledgable on iPad. I might go through the page and try and recoding from scratch using very basic styling and see what happens.


As for stealing the ":hover" style, be my guest. I'm flattered, if anything 🙂


Thanks for all the help, I'll just have a big play around and see if I can perhaps narrow it down to something more concrete.

Sep 10, 2012 11:12 AM in response to jamie.shaw

jamie.shaw wrote:


As for stealing the ":hover" style, be my guest. I'm flattered, if anything 🙂

Thanks. I realize is it just a darker, inset background, but while it's on my mind and in front of me, I'm going to snag it. I would be better at web design if I didn't hate it so much.


The best advice I can give is to try to keep your content and presentation separate. Try to make the site usable even without any styling at all, like in a text-based web browser. Try very hard to use only basic HTML. Don't add divs that serve only the display. Don't have any metadata (like "widebutton" or something) that implies some sort of display attribute.


In most cases, you can build a nice site with just CSS styles. If you are lucky, IE might even render it properly. If not, it is easy to add IE-specific CSS. Only change the structure as a last resort. Even if you get it looking perfectly, some browser update or new version could break it at any time. The fewer hacks and tricks you use, the better your site will handle that stuff.


Next, check it in Firefox. IE9 is actually quite good. Firefox needs more hacks. Finally, check with Chrome. If there is a problem there, change the structure and start again with Safari.


You should also download Validator S. A. C. Your site reports 24 errors. Web browsers will try to correct these errors on their own and that could result in a different structure or CSS interpretation than you expected.

Sep 10, 2012 1:49 PM in response to etresoft

(Not intending to stray OT, etresoft, but this is awesome:


"Validator S.A.C. uses the AppDNA system to bundle the source code inside the application. Every copy of Validator S.A.C. is capable of recompiling itself. To examine the source code, select "Show Source Code" from the Help menu, and the internal XCode project will open."


Thanks for bringing this under my attention!)

HTML /CSS - Different margins on iPad?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.