Recently I wrote about the fundamentals of responsive web design, and how important it was to acknowledge that it wasn’t going away.
When CSS3 became available, it introduced a concept called media queries — which allows presentations to be tailored to a specific range of devices without changing the content itself.
In layman’s terms, this gives us a chance to represent our website in different ways depending on the device that is used for viewing. Whether it be an iPad, iPhone or any other tablet or smart phone, you have the capability of serving up a better viewing experience to your visitors.
Implementing Media Queries
Before I get into the types of media queries that are available, you’ll need a method for detecting the device that is being used for viewing. Thankfully, Apple is smart and came up with the Viewport meta tag which we can use.
If you are using the Genesis Framework to power your website, there’s an easy way to implement this so that it loads properly in the head section of your source code.
Simple place the following code into your child theme’s functions.php file:
[gist id=5708556 file=custom-viewport.php]
In Genesis 1.9 we will be adding a brand new Genesis Responsive function which will use add_theme_support to replace the method above as well as introduce a number of other extremely cool mobile-friendly features.
Now that you have the Viewport meta tag added to your head, now we can move forward with understanding the various types of media queries and how they can be used.
Types of Media Queries
I have a tremendous amount of respect for designer Chris Coyier, so I am going to be unoriginal and rely on his knowledge to present the various types of media queries. Props also goes out to Andy Clark for his hard work which served as the source for the snippets that Chris used.
Thanks to them, we have a an elegant roadmap to using media queries for standard devices. Below are the snippets of CSS that should be added to your theme’s style sheet.
Currently we place them at the bottom of the child theme’s style.css file, but the upcoming Genesis Responsive function will load a responsive.css file if it exists in the theme folder.
You can target general screen viewing areas by changing max-device-width to max-width.
Here’s a list of resources that I found useful while doing research on media queries: