O'Reilly logo

iPhone JavaScript Cookbook by Arturo Fernandez Montoro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scaling to device width

The previous chapter covered the fundamentals of the graphical user interface for the iPhone. Refreshing your mind, we described the viewport as the rectangular area determining how the content of the application displays on the device. This one is an important concept to keep in mind when you're building web applications that have a native look.

How to do it...

We only need one line of code in our HTML files, inside the<head> section:

<meta name="viewport" content="width=device-width" />

How it works...

The viewport area can be controlled through the viewport meta tag defined by the Safari Mobile browser. The width property sets the available width in pixels for the area. Using the value device-width, we can use all available ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required