Mobile Magic
Yesterday I discovered a migic little for making mobile-friendly sites, its the viewport meta tag. It goes something like this:
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
It tells the browser to set the page width to the same size as the targets screen (I am pretty sure it gets mostly ignored on desktop browsers)
This allows you to create variable width pages that will look right on almost any size of screen. Though there are still a few more tricks to perform to make everything look right all of the time. Head on over to HTML5 Rocks for more info.
- nick's blog
- Add new comment
- 3410 reads
Comments
It gets better!
It gets even better with CSS media queries in the stylesheet itself. First, device-width selectors!
Let's say you want to format the page differently based on device orientation:
Want to get crazier?
device-pixel-ratioselectors can detect high-resolution displays (ie iPhone retina, Galaxy Nexus display).There's a bunch more I don't know how to use...yet!
See also:
Supporting high-dpi...with CSS or IMG
How to use CSS3 Orientation Media Queries
Yups! It gets crazier the
Yups! It gets crazier the more you want to fine tune it. So far all I have done is make a mobile friendly front page for the forums. Works on any display size over about a width of 200px I would think (its just a 100% variable width) and looks snazzy enough for my taste. I will throw it up some time after I get a chance to put a few finishing touches on it. Then I will have to make one for all the viewing pages and the signup page and the like.