What Is Responsive Design?
It used to be you only had to worry about website consistency across multiple browsers, but now we have to look at the bigger picture – consistency across multiple devices. The computer used to be our only gateway to the Internet, but now we jump online from our phones, TVs, tablets and who knows what else will come down the pipe. Having your website appropriately render and perform on any device should be a top priority this year.
Responsive design is all about making things fluid and adjusting according to screen size. Although WordPress doesn’t always play nice with responsive design methods, there are ways it can be achieved. How responsive you decide to make your website is really about how much time you want to spend doing it.
There are several responsive frameworks out there to choose from. You might want to spend some time investigating each one to determine which has the included features your project might require. If you aren’t sure where to start, here are a few to consider:
Less Framework is based on 4 layouts and 3 sets of typographic presets. Less Framework uses a default layout as a starting point and then uses CSS3 media queries to code ‘child layouts’.
Foundation is a grid system based on 12-columns that do not have a fixed width; they can vary based on the resolution of the screen or size of the window. Foundation comes pre-packaged with buttons and built in form styles, alerts, and more.
YAML is a multi-column layout based on a grid system with percentage widths. It comes with several built in features and supports several jQuery plugins such as Accessible Tabs and SyncHeight.
This list of frameworks is hardly complete, but for the sake of this tutorial, I’m going to show you how to incorporate Foundation into your next WordPress theme.
Step 1 Downloading and Applying the Framework
To get started, go download Foundation and add the files to your css and js folders in your theme’s directory. The easiest way to add the required files to your theme would be to use
wp_enqueue_script to serve them up.
Next, add the Foundation stylesheets to make the grid flexible. Paste this function after the one you just created.
Once saved, go back and check your source code to make sure your files were added correctly. It should look something like this:
<link rel='stylesheet' id='foundation-style-css' href='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/css/foundation.css?ver=all' type='text/css' media='all' /> <link rel='stylesheet' id='foundation-appstyle-css' href='http://thatonegeek.com/sandbox/wp-content/themes/Starkers/css/app.css?ver=all' type='text/css' media='all' /> http://thatonegeek.com/sandbox/wp-includes/js/jquery/jquery.js?ver=1.7.1 http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/modernizr.foundation.js?ver=1 http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/foundation.js?ver=3.3.1 http://thatonegeek.com/sandbox/wp-content/themes/Starkers/js/app.js?ver=3.3.1
Step 2 Add IE Only Conditions
Everyone loves to go that extra mile to make things work in Internet Explorer right? To make sure your Foundation framework stays responsive in Internet Explorer, you need to add a few conditional statements. These should go in yourfile before the closing head tag.
<!--[if lt IE 9]> <link rel="stylesheet" href="/css/ie.css"> <![endif]--> <!--IE Fix for HTML5 Tags--> <!--[if lt IE 9]> http://html5shiv.googlecode.com/svn/trunk/html5.js <![endif]-->>
Step 3 Working With the Framework
Now that your theme has Foundation setup, to make use of all its responsive features you need to design using the Foundation grid system. Like other responsive frameworks, it’s a system made up of 12 columns. Other included features are pre-set button styles, tabs, tables and much more. Check out the Foundation documentation to view all bells and whistles and instructions on how to work with the grid.
Going With a Pre-Packaged Theme
There are plenty of free and premium WordPress themes available that make use of responsive design. If you would rather start with something out of the box, you can try out these themes:
WordPress Bootstrap is a theme developed on Twitter’s Bootstrap v.2.0.1. It’s fully responsive with four different page templates to choose from, shortcodes, and multiple sidebar options. Once installed, you can check outto download different color versions of the theme.
Based on the Themify framework, iTheme2 uses media queries to target different displays, comes with a customizable feature slider, a social media widget, two different theme skins and you can have up to four footer widgets.
The Responsive Twenty Ten theme supports flexible images, margins, and mobile images. It was created as a child theme for the included Twenty Ten theme.
Good Minimal (Premium)
Good Minimal is a clean, minimalist responsive layout that adapts to a multitude of displays and devices. Good Minimal comes with two different styles, supports unlimited custom sidebars, shortcodes, multiple drop down menus, and several other features.
Responsive design is continuing to grow in popularity and knowing how to utilize it within your future theme construction will be crucial for success. Whether you are adding a framework to your theme or using a pre-built theme supporting responsive design, your clients are going to expect multiple device support as a basic service.