Responsive Design
September 9th, 2011 by Nick Beranek
In the modern age, there is a lot of emphasis on making websites and applications more accessible for a variety of devices. No longer are we developing websites just for a desktop experience, we also need to think about users on handheld devices, iPads, and netbooks. With so many different resolutions to contend with, it is simply not reasonable to create a separate version of your website for each experience.
This is where responsive design comes into play. Responsive design is building your website with every user in mind. You want to make sure that your website will resize properly when viewed in a different viewport.
There are many different ways to achieve this but I’m going to focus on Fluid Design and CSS3 media queries.
Fluid Design
First, I would go ahead and download the Fluid 960 Grid System. This comes in a 12-column or 16-column grid and is percentage-based so that it resizes as the browser does.
Working with a fluid grid should handle most of what you’re looking for, but what about images and divs that need to flow with each other when the screen shrinks? That’s when we use the CSS3 media queries.
CSS3 Media Queries
If you’ve ever built a websites with print in mind, then you’ll understand this concept. This reminds me of a blog post I made about cross-browser compatibility where we talked about the many different ways to design your website with many browsers in mind. Responsive web design takes it a step further where we start thinking not only about IE, Firefox, and Chrome, but also Android, BlackBerry, and Safari mobile.
The way a CSS3 media query works is that if a certain test is passed then you push forward styles that you have developed for a particular resolution or type.
For example, in order to create a test that only serves styles based on a max width of 480px (e.g. the width of the landscape mode of an iPhone), you would create the following query:
@media screen and (max-device-width: 480px) {
img { max-width: 100%; }
}
@mediadeclares the media query.screenlets the browser know that this is primarily for color computer screens (CSS2 specification)- The part within the parentheses is the actual query.
max-device-widthlooks at the width of the screen and says that if the width is less than or equal to 480px than to use the following styles.
There are other ways of achieving this. You can also use the link element that will serve a separate stylesheet altogether if certain conditions are met.
<link rel=”stylesheet” type=”text/css” media=”screen and (max-device-width: 480px)” href=”alternate.css” />
This will serve alternate.css for devices with a max screen width of 480px.
You can even use @import within your stylesheet:
@import url(“alternate.css”) screen and (max-device-width: 480px);
Conclusion
This should be enough to whet your appetite for responsive web design. There are a lot of great articles out there that talk about responsive web design in more detail than I have here:
Thanks for stopping by and keep learning!
Nick Beranek is a Web / Graphic Designer for Interactive Financial Marketing Group.



