views:

111

answers:

2

I'm creating a simple mobile website to render specifically on iPhone. I have been researching the viewport setup in order to have the site fixed at 100% So far I have found that the dimensions are

Portrait: 320px
Landscape: 480px

To render the page at full zoom I have used the following meta tag in the html

<meta name="viewport" content="width=device-width; initial-scale=1; user-scalable=no" />

This works great in portrait, however when the iPhone is rotated to landscape mode the page is not resized accordingly, instead appearing zoomed in.

Can anyone advise on how to correct this behaviour?

+2  A: 

Let's assume your website is wrapped in a container called #wrapper.

We can set the width to 100%, and only allow it a maximum value of 480px. Like so:

#wrapper {
    width: 100%;
    max-width: 480px;
}

You can also listen to the event that fires when the iPhone's orientation changes, i.e. when you flip the phone.

In HTML

<body onorientationchange="someFunction()">

OR In Javascript

window.onorientationchange = someFunction;
Marko
Great solution!
Tom Gullen
+1  A: 
width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0
gustavogb
Thanks @gustavogb, maximum-scale=1.0 sorted it!
WDuffy