Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does <meta name="viewport" content="width=device-width"> do in landscape mode on iOS?

I'm trying to understand the scaling attributes on iOS.

  1. According to Apple's Developer Docs, declaring <meta name="viewport" content="width=device-width"> will tell iOS to scale a webpage to a 1:1 pixel ratio when the page loads (in portrait mode).

  2. According to a presentation by the folks at HTML5Boilerplate (see slide 13), device-width will always correspond to the smaller measure of an iOS device's screen, regardless of the device's orientation.

  3. Therefore, if you load a page in iOS with the <meta name="viewport" content="width=device-width"> declaration while holding the device in a landscape orientation, iOS will set the viewport's width according to what appears to be the screen's height, resulting in a 1.5:1 (iPhone 4s) or 2:1 (iPhone 5) pixel ratio.

Am I correct, or am I misunderstanding the definition of "width" and "device-width" as Apple uses them?

Furthermore, when an iOS device rotates, what does the viewport maintain? It's width, or it's scale? Does it depend on the meta settings?

like image 214
Brandon Lebedev Avatar asked Dec 21 '12 21:12

Brandon Lebedev


People also ask

What does meta name viewport do?

The viewport meta tag allows you to tell the mobile browser what size this virtual viewport should be. This is often useful if you're not actually changing your site's design for mobile, and it renders better with a larger or smaller virtual viewport.

What does meta name viewport content width device width initial scale 1.0 mean and why is it important?

Setting The Viewport The width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device). The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.

What does viewport width mean?

The term viewport refers to the size of a window or visible area on a screen. In general, this term is used for displays on mobile devices such as smartphones and tablets.

What is the default viewport width size for Apple devices?

Default Viewport Settings The default width is 980 pixels.


1 Answers

According to Apple's Developer Docs:

"Similarly, if you specify only the viewport width, the height and initial scale are inferred. Notice that... the landscape orientation maintains a width equal to device-width, which changes the initial scale and has the effect of zooming in when the user changes to landscape orientation."

The article states that iOS keeps the same viewport setting regardless of orientation or rotating the device.

See here, under "How Safari Infers the Width, Height, and Initial Scale".

like image 100
Brandon Lebedev Avatar answered Oct 27 '22 05:10

Brandon Lebedev