Unlimited WordPress themes, plugins, graphics & courses! Unlimited asset downloads! From \$16.50/m

Going Off Canvas with Zurb Foundation 3.0

The hottest trend in the industry today is almost certainly responsive webdesign (RWD). Every day new approaches appear which redefine the way that we think about websites responding to different devices including desktops, tablets and phones. Today we're going to be diving head first into the newest RWD pattern on the block, off-canvas layouts - a very clever approach from the team at Zurb.

In this tutorial, we're going to be creating a simple homepage that has some very special features when viewed on a smaller viewports. While we're going to be working step by step to create the page, we will be getting Zurb Foundation and the Off-Canvas Layouts to do all the heavy lifting for us.

A Few Things Before we Start

As I mentioned, we're going to be building our site based on the hot-off-the-press Zurb Foundation 3.0. Foundation is an advanced responsive front end framework that is often compared to Twitter Bootstrap (Which we have covered here before on Webdesigntuts+). While it's not completely necessary to have used Foundation before, I strongly recommend that you review the Foundation documentation, in particular the Grid section, before you get started on this tutorial.

Secondly, we're not going to be following strict best practices in this tutorial, for the sake of brevity and clarity. For example, we're going to be over-riding the base styles with our own stylesheet, which will have some (very minimal) impacts on performance and an extra HTTP request. I'll be making comments throughout the article whenever another approach may be a better alternative for a production site.

As a quick note on terminology, I'll be referring to the viewport when describing the size of the browser. For example, a 'small viewport' in the context of this tutorial will refer to a browser size (or device) smaller than 768px.

Finally, in the code sections of the tutorial, I'll only be including the -webkit brower prefix where relevant for the sake of brevity. In the downloadable files, all of the browser prefixes will be included.

With all that said, let's take a look at how we're going to be approaching this project.

The Plan Of Attack

Rather than laying out all of our markup first and then returning to style it via CSS - which would quickly get confusing - we're going to build the page in small chunks, starting with our general markup and then fleshing out and styling each section as we progress.

We're going to be approaching the project like this:

• Download all of the required files and setup our file tree.
• Setup the base HTML and CSS.
• Markup and style the components of the desktop version of the site (i.e. wide viewport size), one by one.
• Hookup the off-canvas components.
• Add and override some media queries to enhance the look of the site for small viewports.
• Look under the hood at what powers the layout.

As we've already discussed, this page is going to be based upon Foundation 3.0 and the off-canvas layouts, both developed by Zurb.

Next, we'll need to download the off-canvas layouts from the Zurb Playground.

Unzip both files, but don't combine them just yet - we will need to tweak the document tree, which we'll be covering in Step 3 in a few moments.

We'll be using a few images and assets in our project. Download and extract the source files to use what you see in the demo. The images for the slides are just placeholders however, so you might think about something a little more dynamic to spice things up.

Step 3: Setup the File Tree

Now that we have all of the required files, stylesheets and scripts, let's combine these into a single folder so that we can start getting our hands dirty.

We have to do a little renaming and tweaking here, so be careful to follow these next steps closely:

1. Create a new folder on your desktop and move across the contents of the extracted Foundation 3.0 folder.

2. Rename the index.html file to 'default.html'.
Create a new folder called 'misc' and move the license, robots and humans text files (just to keep everything neat and tidy).

3. From the offcanvas folder that you have downloaded and extracted, move the following files into your main project folder:

• offcanvas-2.html → root
• css/offcanvas.css → /stylesheets/
• js/jquery.offcanvas.js → /javascripts/

4. Create a new folder under 'images' and name it 'site_assets'. Copy across the image files downloaded from the resources (see Step Two.)

5. Create a new folder called 'fonts' and move across the custom font files downloaded in Step Two.

6. Finally, create the following new files:

• index.html
• /stylesheets/style.css

Note: there are several files in the javascripts folder that we won't be using in this project. I've left them in, in case you want to build upon our base and explore the other features of Foundation. For the record, this tutorial requires the following .js files - feel free to delete the remaining scripts:

• app.js
• jquery.min.js
• jquery.offcanvas.js
• jquery.orbit-1.4.0.js
• modernizer.foundation.js

Step 4: Lay Down the HTML Markup

As mentioned already, we're going to be building our page piece by piece, but I do want to make sure that we have a plan to build upon. As such, let's markup our index.html page so we know where we are headed in the following steps.

First, let's setup our <head> and <body> and link up all of the required stylesheets and scripts:

index.html

While everything here should be fairly self explanatory, let's quickly run through the code:

• The HTML5 doctype has been set.
• Added some conditional rules for older versions of Internet Explorer.
• Changed the viewport width (i.e. the width of the browser window) to the width of the device for phones.
• We've linked up the stylesheets that we'll be using during this project, including an 'IE8 and under only' stylesheet Note, you'd ideally want to combine and minify these stylesheets for a production site.
• We'll be using the 'Open Sans' webfont from Google Webfonts in this project. We've included a call to this font in three different weights (300, 400 and 600). View the Open Sans font family.
• We've included a link to the modernizer script and the HTML5 shiv for IE8.
• In the body of the document I've added in some comments to indicate the final structure of the markup.
• Finally, we've linked to our javascript files, including jQuery, Foundation, Orbit (the Foundation slider that we'll be using in this project), and of course, our off-canvas script that will help with the final effects that we're trying to achieve.

Easy peasy so far, right? Let's set up our CSS stylesheet and add a few base styles.

Step 5: Set Up the CSS

Before creating our own style.css stylesheet, we want the ability to read the foundation.css stylesheet (even though we won't be making any changes to it). As the downloaded foundation.css file is served to us minified (i.e. no white space, no trailing semi-colons and no line breaks), it's not very readable at the moment.

To solve this problem, we need to 'unminify' the CSS:

1. Open up the foundation.css stylesheet in your code editor of choice and copy the entire contents to your clipboard.
2. Head over to Peter Coles' Online CSS Unminifier.
3. Paste the copied text into the first window on the site and click the 'Unminify' button.
4. In the second window that appears, copy all the text to your clipboard.
5. Return to the foundation.css file, and copy the clipboard text over the top of the file.
6. Save the document with the same filename and location (/stylesheets/foundation.css)

As the unminified foundation.css is around 2800 lines, we're not going to waste time by navigating the entire file to make changes and insert new styles. Instead, we've already created our own stylesheet called 'style.css' that we will be including new styles and over-riding the base styles set out by foundation.css.

Open up style.css from your stylesheets folder and add the following code:

At this stage, all we have done is created some structure to the stylesheet to help us keep everything organized and logical in the later steps (as defined by the CSS comments), and added a selection of style overrides and some color classes that we will be using in the initial steps.

You'll note that color classes have been added (e.g. .color-one) to our styles. While we could build the colors directly into the page section selectors as we go, this approach allows us to easily modify colors in a single place, as well as giving us a reusable class that can be used to style any elements background anywhere in the page.

Another thing to note is that instead of describing the color classes with their color (e.g. .dark-purple), they are completely non-presentational, allowing us to change the colors at any time or even reuse the code in another project without being locked in to presentational class names.

I've also removed the default padding from the section elements as we'll be creating a full width layout.

The default .row class set in foundation.css is 1000px, which is a tad too narrow for our layout. We've changed this to 1024px.

Next, I've added a .full-width class that will allow us to create our 100% width section 'bands' in our layout.

Finally, under the 'Typography' section, I've also set some base styles for our header and paragraph elements.

Columns? Rows? Full Width classes? Confused? Don't be. Let's take a flyby review of how Foundation works.

Step 6: A Five Minute Review of Foundation

You have read the Foundation documentation, and have an understanding of how a Foundation page is structured, right?

No? Let's get you up to speed.

A webpage built with Foundation follows a set format that allows you to create a multi columned, responsive layout very quickly and very easily.

The following diagram gives you an overview of the general structure that we'll be using today:

This is a very simplified overview, but it will serve our purposes to explain the Foundation grid system.

Firstly, Foundation 2 requires a container div to wrap all of its child content within. This requirement has been removed in the latest code base of Foundation 3.0, meaning that row divs can be included directly under the <body> tags.

Secondly, to achieve our colored 'bands', each section is wrapped in a div with a class of .fullwidth. The background color will be added in with an additional class (.color-one, .color-two, etc.), which we added in the previous step.

Next, each part of the site is wrapped in a div with a class of .row In the last step, we set the width of the row div at 1024px. In fact, we could set this width at any width to suit our needs and the Foundation grid adapts to the width without us needing to change any other CSS.

Contained in each .row div are up to twelve divs with a class of .column, depending on the layout you want to achieve. So, for example, for content that stretches the full width of the row, we would use apply the classes of .twelve .columns. In the second example (which is representative of a page with a main content area and a side bar), inside our row you would have two divs, one with a classes of .eight .columns and another with classes of .four .columns.

When the browser window is resized to a smaller viewport (or a small device is used to view the site), the columns automatically stack on top of one other as per the rules set out in foundation.css stylesheet - that's right… with just a little bit of markup, your site is automatically responsive (cool, huh?).

Finally, in the last example in the above image, we can center a column horizontally within the row by applying the additional class .centered (note, this only centers the div, not the content inside it).

To make these concepts clearer, let's code the three examples in the image:

An important concept to understand about the Foundation grid system is that column widths are measured in percentages, meaning that they automatically adjust to fill the row (or nested row) that they are children of.

Another thing that is very important to note is that columns stretch to 100% of the width of the row - in fact, the Foundation grid system uses box-sizing on all elements, so there is no padding or margins between columns (the spacing in the image above is only representational to illustrate the broad concepts of the grid system).

It should also be noted that you are able to nest infinite rows within columns (well, within reason, anyway). While we won't be doing much nesting of rows within columns in this tutorial, this is a very powerful layout technique and gives the ability to create extremely sophisticated layout patterns.

Still confused, or you'd like to delve into the grid system some more? I highly recommend that you review the extensive documentation on the Foundation site.

And with that whistlestop tour of the basics of the Foundation grid system, let's get into some code!

Step 7: Markup the Header Section

For our header, we want a logo to the left of the page and a simple navigation bar that will float to the right side of the page. When the viewport of the browser or the device reaches a width of 768px and under, we want a number of things to happen:

1. The logo will be the topmost element of the site, and will remain aligned left to the browser window.
2. The navigation bar will become hidden.
4. When the menu button is pressed, a mobile navigation menu will dropdown from the top of the screen.
5. When the 'off-canvas' button (as we will call it for now) is pressed, the main screen will move to the right and a supplemental panel will slide out from the left of the panel.

We will be tackling steps four and five later on in the tutorial, but we have everything that we need baked right into Foundation to achieve steps one to three.

First, since we know that our logo and our navigation bar will occupy two ends of the same row, we can easily lay this out with the .row and .column classes discussed in the last step.

In your index.html file, add the following code directly under the header comment (underneath the <body>) tag:

There are a few things to comment on in this code block - including the utilization of a number of Foundation's features.

First, you'll notice that we have wrapped our logo in a div with a class of .five .columns and our navigation bar (and the extras) in a .seven .columns div, as per our introduction to the grid system in Step Six.

As I mentioned, at smaller screen sizes, we want the main navigation to be hidden from view. Using Foundation, this is as simple as adding the class .hide-for-small, which effectively sets display: block; in viewports greater than 767px sets display: none; for the element in smaller viewports (take a look at the unminified foundation.css code from line 547 – 565 for a better understanding of this).

In the opposite way, the two buttons in the 'small screen extras' section are hidden from view on large screens (>767px) and displayed on smaller screens by adding the .show-for-small class to the <p> element.

We've also added some ids to the small screen buttons that will help us in the later stages of the tutorial.

Make sure that the the footer tag is closed right above our javascripts and <body&rt; tag at the bottom of the page - all of the markup for the remaining site components will be wrapped in this div.

Now that we have established the markup, let's style the individual components.

In your style.css file, under the 'Layout' section, add the following code:

You'll see that there is nothing too groundbreaking here. We've simply set a minimum height for the <header>, added a 5px border to the full width div with the inclusion of the .first class and set some basic positioning for the logo.

Currently, the <h1> element sits on top of the logo image. We'll want to remove the this header from view but still include it in the markup for SEO and accessibility purposes.

Under the 'Typography' section of style.css, add in the following code:

Here, we've set the h1 to a font size and line height of 0%, removed any legacy text shadow and removed any text color.

Under the 'Primary Navbar' section of the style.css stylesheet, add in the following code:

In this CSS, we are taking the base styles from foundation and applying style more suited to our design.

The default styles in Foundation create borders for the navigation <li> elements in two ways, first by applying a 'border-left' attribute and secondly by applying a 1px box shadow. Since we don't want any borders, both the border and box-shadow attributes need to be set to 0.

In addition to the base styling, I've also added a simple transition to the hover state of the <li> items that adds a little polish to the menu. It's also worth pointing out that as well as applying the transition to the hover state, I've also applied the same transition to the normal state, so when the mouse hovers off the element, the effect 'rewinds'.

The only other thing of note in this code block is the use of pixels instead of ems for the link elements. While it's often a good idea to use ems (or rems) for text elements in your projects to allow users to define their own text size, in this case we want to ensure that users can't resize their text so as not to break the layout of the navigation bar (of course we can't do anything about zooming, however!).

We also need to style the small-screen-extras buttons.

In the 'Buttons' section of your style.css stylesheets, apply the following code:

All we are doing here is building upon the existing styling from foundation.css. What that means is that we need to change some colors and we can still take advantage of all of Foundation's sweet transitions.

Note: these changes will flow on to any other buttons in the page. If we wanted a button of a different color later on (for example a submit button), we could easily target it with an additional class name.

Great! That's our header finished (for the moment). If you resize your browser window, you'll be able to see Foundation in action. Of course, our small-screen-extra buttons don't do anything (yet).

Step 9: The Slider

For the next section of the site, we'll be adding a simple slider that will scroll through three full-width images. In addition, the slider width will resize to the width of the border, and will also become hidden on screens smaller than 767px.

Sounds complicated? Actually, it's quite simple. We'll be using Foundation's built in slider "Orbit" plugin which is extremely easy to hook up and customize to meet our needs.

Under the 'Slider' section in your index.html file, add in the following code:

You'll see here that we've wrapped the slider (with an id of "featured") in a div with a class of .hide-for-small that will change the slider to display: none; for screen sizes <767px. Both of these divs are wrapped in a .full-width div.

Styling the slide show couldn't be easier. In your style.css stylesheet, add the following CSS under the 'Layout' section:

Finally, we need to call the Orbit jQuery script. At the bottom of your document before the </body> tag, add the following script:

Before we move on, there's just a couple of quick things that I'd like to mention.

Firstly, depending on your Foundation build, you may need to change the file path of the Orbit images (arrows, timers, bullets, etc.) to the correct location in your file tree (../images/foundation/orbit/..). You can do this quite simply by completing a find / replace in your foundation.css stylesheet, or update them manually between lines 2448 and 2659 of the unminified foundation.css file.

Secondly, we won't be customizing the slider past the base styles. There are a bunch of different options, transitions and more that you can apply to the slider. To learn more about extending the Orbit slider, refer to the Foundation Orbit Documentation.

Thirdly, I'd like to point out that there would be performance issues with this solution for small screens if put into the wild. The .hide-for-small class simply sets display: none;, and does not actually stop the device from downloading the images. This means that a mobile phone on cellular data would be downloading three sizable images for - essentially - nothing.

This is a tricky topic and is out of scope for this tutorial, however a possible solution may be to use AJAX to load in the images for large screen sizes.

Step 10: The Callout Section

The next step is to add a simple callout or slogan to the site underneath the slider.

Under the 'Callout' section in the index.html, add the following code:

In this HTML we've set up a full width column div .twelve .columns, and added a class of .callout to the row that will allow us to style the callout text.

Next step is to add some styling for the </code> element.

Under the 'Typography' section of the style.css stylesheet, add the following code:

Note: all of these attributes except for color and margin-bottom are identical to the h1, h2 & h3 selectors that we have already defined. While it's fine to add the .callout p selector to this stack, I've chosen to define it separately in case we would want to either change the style of any of these elements or reuse the code for a future project. As always, there's pros and cons to both approaches and I'll leave the final choice with you.

Next, add the following CSS to the 'Layout' section of the stylesheet:

Step 11: Markup the Services Section

In the services section of the site we want three side-by-side panels that will stack on top of one another on small viewports.

Under the 'Services' section in your index.html, add in the following markup:

You'll see that we've created a single .row div wrapped in a .full-width div. In the row, we've created three .four .columns div and added in an additional class of .service to each.

We'll add a little padding to the .service class in the 'Layout' section of the style.css stylesheet:

Step 12: Add Content and Style the Service Panels

For the content of each service panel we'll be including an icon font (downloaded from IcoMoon to add a visual representation of the relevant service, a header, some lorem ipsum text and a 'read more' button:

You'll note that we are using the data-icon selector along with the relevant unicode for each heading to include the icon in our page. I don't want us to lose momentum, so I won't go into this in much detail. Having said that, if you want to read more about why data-icon is a preferred method for this application, Chris Coyier has a good overview of HTML for Icon Font Usage over on CSS Tricks.

For your reference, the unicode pairings for our icon font are as follows:

• &#x6e = Screen Icon
• &#x21 = Pencil Icon
• &#x22 = Graph Icon

Next, we will style the <h3> element, hookup the IcoMoon <@font-face> and style the icons.

In the 'Typography' section of your stylesheet, add in the following code:

In this code block, we are referencing the IcoMoon fontface with preferred formats for the various browsers.

Next, in the 'Layout' section of the stylesheet, add the following code:

The comments here should be fairly self explanatory, but in essence this block of CSS creates a 60px high white icon centered in the middle of a circular disc with a diameter of 120px. A chained set of box-shadows gives the disc a subtle 'letterpress' effect. We've also defined the height of all elements in pixels (instead of ems) to give us control over users that resize their default text size in their browsers.

The span that wraps the button is set to width: 100%; and text-align: center; to ensure that the button aligns itself to the horizontal center of the service column.

Great! We're making excellent progress. Let's move on to the featured project section of the site.

Step 13: Markup the Featured Project Section

In this section of the site, we're aiming to add an image of a featured project that is aligned to the center of the page. When we scale down the browser size, we also want this image to respond to the new viewport width and automatically scale down to an appropriate size.

The markup for this section of the site is fairly straight forward:

Styling our featured project is nice and easy, too.

The way that we've positioned the image is worth talking about briefly. Since we know that the width of the image is 600px, we can accurately center the image to its parent by adding position:relative, setting the left position to 50% and then giving it a negative left margin of 300px (half the width of the image).

Step 14: Markup The Contact Section

Creating forms for any website is never a fun job, but luckily for us, Foundation makes the job about as painless as possible. Not only can we use and build upon the default styling from the foundation.css stylesheet (which is quite nice in itself), we can also use rows and columns to control the widths of our input and text area fields.

Let's add in the following code underneath the featured image section of our page and then we'll discuss the way that we have controlled the layout of the form:

The first thing that you will notice is that we have taken advantage of the .centered class to align the ten columns div to the center of the row. Doing this will ensure that the form remains neat and the input elements do not stretch too wide.

Next, you'll see that we have nested a row and a six-column div inside the form to control the width of the input fields. Remember, that because our columns are all measured in percentage widths, the width of a nested column is relative to its parent (in this case the .ten .columns div), and not the 1024px that we have set for all <div class="row"> elements. In other words, a .six .columns div will always be half the width of its parent.

Next, we have closed the row housing the .six .columns div and created a new row that has a child div with classes of .twelve .columns that give the textarea a width of 100% of its parent (which is still the ten column div).

As I mentioned before, the default styles of the Foundation forms are perfectly acceptable as they are, but with that said, we'll tweak a few of the styles so that they fit will with our overall design.

Under the 'Forms' section of your stylesheet, add in the following CSS:

Step 15: Create the Footer

The final step for our basic page is to add a (very) simple footer.

Add in the following code underneath the 'Footer' section of the index.html file:

Also add in the following CSS to the 'Layout' section of your style.css stylesheet:

Step 16: Hook Everything up with Off-Canvas

You've done really well to get this far. Take a break and give yourself a well deserved pat on the back. Just don't rest for too long... the exciting stuff is still to come.

Our next step is to hookup our markup into the off-canvas syntax to achieve the desired effects at small viewport sizes.

Let's just step back for a moment and review what we want to happen when the page is accessed on small viewports:

1. The main navigation will become hidden, and when the 'Menu' button is pressed a navigation menu will slide into view from the top of the page.
2. When the 'Contact Us' button is pressed, the main content will slide to the right, being 'pushed' out of the way by the contact form.

We'll add these functions to our HTML, style the elements as required and then return to take a peek under the hood and learn how the off-canvas layout do their magic.

Let's start by setting up the page for off-canvas.

Step 17: Add an Additional Class to the Body to Call Off-Canvas

As our very first baby step, add a class of "off-canvas" to the <body> tag of your index.html:

Next, we'll set up our slide-navigation for small viewports.

Return towards the top of your index.html file and add in the following code between the <div class="bpdy"> tag and the <div class="first full-width color-three"> tag:

The most important thing to note here is the <nav> element. You'll see that we've given it an id of "topMenu" which will trigger the menu when the menu button is pressed and we've also assigned a role="navigation" to the element. It's the latter that the offcanvas.css stylesheet will pickup and apply the result.

It's important to note that we've essentially repeated ourselves here by duplicating our main navigation menu. Not only have we repeated code that goes against the principles of DRY (don't repeat yourself), it also means that if we want to change the navigation menu in any way (e.g. add extra items or include a drop-down menu), we'd need to also change the small viewport navigation menu too... not a great solution for a dynamic site.

A better solution would be to use the jQuery clone() element and append it to the small viewport menu, something along the lines of:

Check out the codepen to see this solution in action.

With all that said, to keep things simple, we'll acknowledge the problems with the duplicate menu solution and run with it for the sake of simplicity.

In the 'Media Queries' section of your style.css stylesheet, add in the following:

In this small piece of CSS, we've added instructions for the browser to remove the borders for the <li> and a.main elements on viewports 767px and smaller.

If you've followed along closely, you'll be able to see the small viewport navigation menu in action. Save your changes, hop over to your browser, refresh the page and resize the window to a small size. When the 'Menu' button is pressed, you should see our new navigation menu slide into view.

The next step is to alter our markup to let offcanvas.css and offcanvas.js know that we want to send the contact form section of the site off-canvas and slide it into view when only the 'Contact Us' button is pressed on small viewports.

To do this, we'll need to wrap our markup in two separate <section> elements and assign roles to these elements.

Just in case that isn't clear, you'll want to start the <section role="main"> directly under the <header> and close it directly under the 'Featured Project' code. Next, you'll want to wrap all of the 'Contact Us' code in the <section id="contact" role="complementary"> element. The site footer continues as normal underneath the closing <section>.

Next, we'll need to override some of the offcanvas.css base styles to ensure that our layout doesn't break with our new <section> elements.

In your style.css stylesheet under 'Off Canvas', add in the following code:

The most important thing to note here is the setting of the .js [role="complementary"] and .js [role="main"] widths to 100%. In the default styling of the off-canvas layout, these elements are set to a main content / sidebar layout. Changing the widths to 100% ensures that the linear layout that we've created is maintained.

With those changes, we are now very close to completing our project. At this stage, you can resize your browser down to a small size, click the 'Menu' and 'Contact Us' buttons and see all of the off-canvas functionality in action.

All that remains at this stage is to tidy up some loose ends and style some of our elements for small viewports.

Step 20: Style the Page for Small Device Widths

As it is, the page is perfectly acceptable in terms of design, but a few elements of the site need a little polishing for small viewports.

In your style.css stylesheet, add the following CSS to the 'Media Queries' section, before the closing curly bracket of the media query that we've already created. I've included all of our media query in the following code block, but remember that we've already created the first three selectors in Step 15:

And with that, we've finished! Great work!

Step 21: Looking Under the Hood

I'm sure that by now you are looking forward to a coffee (or perhaps something stronger!) and a well deserved break.

I won't be going through each line of code with you, but I did want to take this opportunity to take a quick look behind the scenes at the off-canvas code to show you in simple terms how we've achieved what we've achieved today.

To start off with, as I'm sure that you've already picked up, the most important hooks in our code are the role attributes given to each of the two <section> elements in our markup. While the use of roles is not the only way to accomplish the off-canvas effect, they do add an extra layer of elegance and accessibility to the code.

Accessible Rich Internet Application (ARIA) roles are a small part of the Web Accessibility Initiative and allow website developers to add additional information to elements that can add extra context for visitors to the site that are using screen readers. While the list of available roles is extensive, we've used the two navigation roles of 'main' and 'complementary', which when you think of it is quite appropriate for our purposes today. While it's a slow read, you can read more about roles from the W3C.

In terms of functionality, the first thing that the off-canvas layout does is to position the small viewport navigation menu off of screen on large viewport sizes with the following javascript:

And with the CSS, the default display type is set to display: none; on wide viewports:

Next, the jquery.offcanvas.js javascript applies a class of 'active' to the body element when either of the small viewport panels is selected:

When the 'active' class is applied to the body, the offcanvas.css stylesheet repositions the section with role=[main] 80% to the right and sets the role=[complementary] section to a margin: 0;:

This is a pretty simplistic view of the workings of off-canvas, but serves to give you a high-level overview of how the layout works. I highly recommend digging into offcanvas.css and jquery.offcanvas.js to bring yourself up to speed with the intricacies of the code.

Conclusion and Review

If you've followed along to this point, congratulations! Today we've jumped straight into the the deep end with Foundation and off-canvas to produce a functional, practical home page layout that has real-world applications that is bound to impress your next client.

This is only one of the off-canvas configurations that we could have used today. In fact, in the offcanvas downloads are three additional layouts for you to play with. Just open up the .html files and insert your own code to experiment and customize your own off-canvas pages.

If you have any questions, please leave them in the comments and I'll try my best to answer them for you.

Did you enjoy working with Foundation? Would you like to see more tutorials in the future exploring this framework? If so, please let us know!

Changelog: 22 October 2012

Since the publication of this tutorial Foundation has altered in a few subtle ways. Other best practices in web design have also emerged, so I've updated the tutorial to reflect these changes.

 edited instructions within step 6 re: containers in foundation 3.0 removed <div class="container"> tags, rules and references throughout the tutorial, index.html and style.css files changed the hidden h1 method from position: absolute; left:-9999px to font:0/0 a; etc. removed extra <div class="row"> x2 from step 11 changed the footer to include links