Archive for March 2013

Controlling Mobile Browser Layout

Published on March 26, 2013

I’m currently working on converting this site’s layout to a fluid, responsive-design variant, which will make the site much more usable on mobile devices (as of this writing, the mobile experience is pretty bad). In my efforts to improve the design, I noted that the browser on my Android phone didn’t respond to my changes at all. The Responsive Design View in Firefox yielded acceptable results, as did the developer tools available in Chrome (which, by the way, are pretty terrible). So why did my phone look so different?

The answer has to do with the concept of the viewport. I found a terrific pair of articles detailing the ideas behind viewports on both the desktop and mobile devices (be sure to read the desktop article first; it sets the stage for the second). It turns out that my page’s header was missing a key meta element, whose very existence we can thank Apple (of all people) for. The tag looks like this:

<meta name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=8" />

Using this meta entry allows devices to scale their layout viewport appropriately. Adding this one element fixed my phone, causing the site to render as expected. There are other articles that discuss this element better than I could, so give them a look. And don’t forget this one line if you’re designing responsively; it’ll save you a lot of potential headache!

Copyright © 2004-2018 Jonah Bishop. Hosted by DreamHost.