Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set viewport meta for iPhone that handles rotation properly?

So I've been using:

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"/> 

to get my HTML content to display nicely on the iPhone. It works great until the user rotates the device into landscape mode, where the display remains constrained to 320px.

Is there a simple way to specify a viewport that changes in response to the user changing the device orientation? Or must I resort to Javascript to handle that?

like image 793
George Armhold Avatar asked Aug 04 '09 21:08

George Armhold


1 Answers

Was just trying to work this out myself, and the solution I came up with was:

<meta name="viewport" content="initial-scale = 1.0,maximum-scale = 1.0" /> 

This seems to lock the device into 1.0 scale regardless of it's orientation. As a side effect, it does however completely disable user scaling (pinch zooming, etc).

like image 83
Tobias Cohen Avatar answered Oct 05 '22 03:10

Tobias Cohen