views:

598

answers:

2

I have a small mobile phone app that is acting strangely on the iPhone/Mobile Safari. The page renders and works great when it's orientation is vertical. When I rotate the phone horizontally some, but not all elements on the page resize correctly. Some header elements will stay nearly their same size, maybe increasing by 10%, others will double in size.

Has anyone run into this? My first thought was that the css could have a mix of sizes based on ems and px's but finding every size element and converting them to em's didn't change a thing.

+2  A: 

Have you tried including a viewport meta tag, such as this:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

Otherwise, you could try creating orientation-specific CSS stylesheets and swap them out w/ javascript when the orientation change event fires, but I prefer the meta tag method above.

Brian Driscoll
I did have a viewport meta tag. This was a pretty strange bug and I never actually found a solution (It was part of an internship and I went and got job so I'm no longer on the project).
Michael
Wow just encountered the same problem. added the scale values to the meta tag fixed it on refresh. (Before I only had the user-scalable.)Weird though.
Ian Storm Taylor
+1  A: 

It's because Mobile Safari on iPhone & iPod Touch does automatic font-size adjustment.

You can disable it with the following css rule,

html {-webkit-text-size-adjust:none}

More info from Safari Reference Library

Livingston Samuel