Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS ignoring meta viewport width=device-width, initial-scale=1.0

When I view the following html file with Safari in an iphone, it does not display the entire width of the content as it's supposed to:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>iOS Viewport Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style type="text/css">
body #wrap {
    width: 1008px;
    border: 1px solid #000;
}
h1 {
    font:30px sans-serif;   
}
</style>
</head>

<body>
<div id="wrap">
<h1>Here's some quite eloooongated text that should make the screen at least 1008px wide or more</h1>
</div><!-- end #wrap -->
</body>
</html>

Can anyone see what I'm doing wrong? For what it's worth, I have iOS 6.1 and Safari 6.0

like image 571
yitwail Avatar asked Jun 18 '13 04:06

yitwail


People also ask

What is initial scale 1.0 meta tag?

The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser. Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag: Without the viewport meta tag.

How do I turn off viewport scaling?

To disable pinch-zoom in HTML, simply add <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> to the <head> section.

What is the default viewport width size for Apple devices?

Default Viewport Settings The default width is 980 pixels.

Why is viewport not working?

Solution: Make sure the layer has not been turned off or frozen: In the Layer Properties Manager, make sure the layer that contains the viewport geometry is not turned off or frozen. Go to the layout tab that contains the problem viewport.


2 Answers

Even though I read apple's various viewport guidelines very carefully, apparently I misunderstood. If a site is non-responsive, like mine, the correct meta in this case is

<meta name="viewport" content="width=1008"/>

This makes the viewport fit the content in both portrait & landscape orientation. There's a discussion of this approach here: http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design

like image 117
yitwail Avatar answered Nov 15 '22 09:11

yitwail


I was googling to see if anyone else had encountered this issue as well. Thought I'd share my results.

My non-responsive site is about 1200px wide, and I wanted it to show the whole site's width while in portrait mode. Setting the scale to 0 also seems to work on what I've tested:

<meta name="viewport" content="width=device-width, initial-scale=0"/>
like image 26
alanvitek Avatar answered Nov 15 '22 09:11

alanvitek