<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Saddam Azad - User Interface Designer &#38; Front-end Engineer.</title>
	<atom:link href="http://azadcreative.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://azadcreative.com</link>
	<description>Journal and Portfolio of Saddam Azad, User Interface Designer and Front-End Web Developer</description>
	<lastBuildDate>Mon, 31 Dec 2012 07:41:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Conditionally Enqueue Scripts and Styles for WordPress Post Formats</title>
		<link>http://azadcreative.com/2012/08/enqueue-scripts-styles-wordpress-post-formats/</link>
		<comments>http://azadcreative.com/2012/08/enqueue-scripts-styles-wordpress-post-formats/#comments</comments>
		<pubDate>Wed, 15 Aug 2012 11:46:29 +0000</pubDate>
		<dc:creator>Saddam Azad</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://azadcreative.com/?p=821</guid>
		<description><![CDATA[<p>Post Formats are still uncharted territory for a lot of Wordpress developers. I have demonstrated a method of keeping the code itself and the final markup as squeaky-clean it is supposed to be. Instead of loading all the resource libraries, only load them when they are needed - and do so in the most elegant fashion possible.</p><p>The post <a href="http://azadcreative.com/2012/08/enqueue-scripts-styles-wordpress-post-formats/">Conditionally Enqueue Scripts and Styles for WordPress Post Formats</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Those of us who are WordPress theme developers, are all too familiar with the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">wp_enqueue_script</a> and <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style">wp_enqueue_style</a> that are default WordPress functions for appending scripts and styles, respectively, to our themes.</p>
<p>However, the recent updates to WordPress enables developers to provide different <a href="http://codex.wordpress.org/Post_Formats">Post Formats</a>. According to the Codex:</p>
<blockquote><p><strong>Post Formats</strong> is a theme feature introduced with Version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature.</p></blockquote>
<p>This is perhaps an attempt to level with Tumblr which is build around this very concept. However, WordPress provides very little guidelines as to how to work with the different Post Formats. I suppose the core team is leaving the details to the large ecosystem of designers and developers to figure out what to do with this new feature.</p>
<h2>The Basic Structure</h2>
<p>Post Formats have opened a world of opportunities for designers and developers. We are no longer limited to the mundane blog posts that WordPress is so darn good at publishing.</p>
<p>For the purpose of this tutorial, let&#8217;s say we are supporting the gallery, audio and video Post Formats. This can be done with a quick snippet in the functions.php</p>
<pre>add_theme_support( 'post-formats', array( 'gallery' , 'video' , 'audio' ) );</pre>
<p>However, developers have been struggling to keep their implementation of Post Formats clean and bloat-free. The most common approach seems to be using if/else conditions within template files and providing the markup for each Post Format &#8211; all within a single document. This is, of course, very inefficient and can get very bloated very quickly.</p>
<p>I find the most efficient manner of integrating Post Formats is this code snippet in the index.php and single.php templates:</p>
<pre>&lt;?php if ( have_posts() ) :
  while ( have_posts() ) : the_post(); 
    get_template_part( 'content', get_post_format() );
  endwhile;
endif; ?&gt;</pre>
<p>For each Post Format you support in your theme, there must be a separate template containing the markup. For instance, for the gallery format, the filename would be <span class="highlight">content-gallery.php</span> and likewise for all the other formats you choose to support.</p>
<p>In case your theme does not have the appropriate template, it will fall back to the default <span class="highlight">content.php</span>.</p>
<h2>Functions.php</h2>
<p>Firstly, we create a function within functions.php with the only parameter being Post Format:</p>
<pre>function enqueue_post_format_resources($format) {

if( in_array($format, array('gallery')) ) {
  wp_register_script('galleria', get_template_directory_uri() . '/js/galleria/galleria.js', false, false);
  wp_register_script('galleriatheme', get_template_directory_uri() . '/js/galleria/classic/galleria.classic.js', false, false);
  wp_register_style('galleriathemecss', get_template_directory_uri() . '/js/galleria/classic/galleria.classic.css', false, false);
  wp_enqueue_style( 'galleriathemecss' );

} elseif( in_array($format, array('audio', 'video')) ) {

  wp_register_script('mejs', get_template_directory_uri() . '/js/mejs/mediaelement-and-player.min.js', false, false);
  wp_register_style( 'mejscss', get_template_directory_uri() . '/js/mejs/mediaelementplayer.min.css', false, false );
  wp_enqueue_style( 'mejscss' );

} else {
  return false;
}

}//end function</pre>
<p>We are checking if the given format matches a certain criteria. Firstly, we check if it is a gallery &#8211; in which case, we will register and scripts and stylesheets of the fantastic <a title="Galleria - Responsive JavaScript Image Gallery" href="http://galleria.io/" target="_blank">Galleria</a> javascript library.</p>
<p>Secondly, we check if the Post Format is either audio or video. In this case, we register the resources of <a title="MediaElement.js - HTML5 video and audio made easy" href="http://mediaelementjs.com/" target="_blank">MediaElement.js</a> &#8211; which is an outstanding library for handling HTML5 Audio and Video in all browsers.</p>
<p>You have the liberty to add any library or polyfill as you see fit and set conditions for a particular Post Format.</p>
<p>One curious thing about the code above is that only the stylesheets are being enqueued, but not the scripts. This is because we are going to <a href="http://stackoverflow.com/questions/9315165/modernizr-load-method" target="_blank">lazy-load</a> the scripts within the theme using <a title="Modernizr - YepNope.js" href="http://modernizr.com/docs/" target="_blank">Modernizr</a> (discussed below). However, this step is entirely optional. You can go ahead and use wp_enqueue_script for each of the registered scripts above. That will directly print the code in your theme&#8217;s <span class="highlight">wp_footer</span>.</p>
<p>We will need a custom script that displays the enqueued script:</p>
<pre>/* 
* Display the enqueued scripts
* URL: http://jamesfishwick.com/2011/modernizr-and-jquery-and-wp_enqueue_script-oh-my/
*/

function registered_scripts( $handles = array() ) {
   global $wp_scripts, $wp_styles;

   foreach ( $wp_scripts-&gt;registered as $registered )
     $script_urls[ $registered-&gt;handle ] = $registered-&gt;src;

    foreach ( $wp_styles-&gt;registered as $registered )
      $style_urls[ $registered-&gt;handle ] = $registered-&gt;src;

    if ( empty( $handles ) ) {
      $handles = array_merge( $wp_scripts-&gt;queue, $wp_styles-&gt;queue );
      array_values( $handles );
    }

    $output = '';

    foreach ( $handles as $handle ) {
      if ( !empty( $script_urls[ $handle ] ) )
        $output .= $script_urls[ $handle ] . ',';

     if ( !empty( $style_urls[ $handle ] ) )
        $output .= $style_urls[ $handle ] . ',';
    }

  $output = substr( $output, 0, -1 );
   echo $output;

}// end function</pre>
<p>I will allow the original author of this snippet <a title="Modernizr and jQuery and wp_enqueue_script" href="http://jamesfishwick.com/2011/modernizr-and-jquery-and-wp_enqueue_script-oh-my/" target="_blank">James Fishwick explain the functionality of registered_script()</a>.</p>
<h2>content-{format}.php</h2>
<p>Now that we have set up a script that registers and enqueues scripts and styles based on the post format that is passed along as a variable, we can now include this snippet at the beginning of each content-{format}.php file:</p>
<pre>&lt;?php enqueue_post_format_resources( get_post_format() ); ?&gt;</pre>
<p>Hence, when the Post Format is <span class="highlight">video</span>, the function will be called to enqueue all the necessary resources appropriate for this format &#8211; which is, in this example, the components of MediaElement.js.</p>
<h2>Loading Registered Scripts with Modernizr</h2>
<p>In functions.php, I only loaded the stylesheets using wp_enqueue_style but left out the javascript files. The purpose for this is that we are going to be using Modernizr for loading the script resources.</p>
<pre>&lt;script type="text/javascript"&gt;
Modernizr.load([
  {
    load: '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js',
    complete: function () {
      if ( !window.jQuery ) {
        Modernizr.load('js/jquery-1.7.2.min.js');
      }
    }
  }
  &lt;?php if( wp_script_is('galleria', 'registered') ) { ?&gt;,{ load: '&lt;?php registered_scripts( array('galleria') ); ?&gt;' } &lt;?php } ?&gt;
  &lt;?php if( wp_script_is('galleriatheme', 'registered') ) { ?&gt;,{ load: '&lt;?php registered_scripts( array('galleriatheme') ); ?&gt;' } &lt;?php } ?&gt;
  &lt;?php if( wp_script_is('mejs', 'registered') ) { ?&gt;,{ load: '&lt;?php registered_scripts( array('mejs') ); ?&gt;' } &lt;?php } ?&gt;
  ,{ load: '&lt;?php registered_scripts( array('behaviour') ); ?&gt;' }
 ]);
&lt;/script&gt;</pre>
<p>Firstly, we make a query to the Google CDN for hosted version of jQuery. There is a fallback in case the CDN file fails to load. The fallback is self-hosted within the theme&#8217;s own directory structure.</p>
<p>Once it has been ensured that jQuery is loaded &#8211; by whichever means &#8211; we are going to load the resource files necessary for the Post Format.</p>
<p>We are using lesser-known <a href="http://codex.wordpress.org/Function_Reference/wp_script_is">wp_script_is</a> function to check if a particular script is registered. The scripts for the audio and video Post Format are only registered when such a post is being rendered. If the script is registered, it definitely means that an audio/video post is currently being rendered &#8211; so we load the necessary script using <a href="http://modernizr.com/docs/#load">Modernizer.load()</a>.</p>
<h2>Limitations</h2>
<p>The stylesheets loaded using wp_enqueue_style are, by default, added to the <a href="http://codex.wordpress.org/Function_Reference/wp_footer">wp_footer</a>, meaning that your stylesheets will end up at the bottom of your document. This is bad web design practice.</p>
<p>You could also load your CSS resources just like the Javascripts, but you will need to add <a href="http://stackoverflow.com/questions/7670298/load-external-google-fonts-stylesheet-with-yepnope-modernizr">CSS Prefix</a> to your copy of Modernizr. WordPress happens to have a function <a href="http://codex.wordpress.org/Function_Reference/wp_style_is">wp_style_is</a> which serves the purpose of checking whether a stylesheet is registered. Instead of enqueueing the stylesheet directly from functions.php, you can load them using Modernizr in the same manner as the scripts.</p>
<h2>Conclusion</h2>
<p>Post Formats are still uncharted territory for a lot of WordPress developers. I have demonstrated a method of keeping the code itself and the final markup as squeaky-clean it is supposed to be. Instead of loading all the resource libraries, only load them when they are needed &#8211; and do so in the most elegant fashion possible.</p>
<p>After all, code is poetry.</p>
<p>The post <a href="http://azadcreative.com/2012/08/enqueue-scripts-styles-wordpress-post-formats/">Conditionally Enqueue Scripts and Styles for WordPress Post Formats</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://azadcreative.com/2012/08/enqueue-scripts-styles-wordpress-post-formats/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Building a Responsive, Mobile-First Navigation Menu</title>
		<link>http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/</link>
		<comments>http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/#comments</comments>
		<pubDate>Sun, 01 Jul 2012 14:27:11 +0000</pubDate>
		<dc:creator>Saddam Azad</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://azadcreative.com/?p=805</guid>
		<description><![CDATA[<p>This tutorial will demonstrate how to develop a complex responsive navigation menu using the “Mobile-First Approach“. The aim is to present mobile users with a pseudo-native, touch-conducive and interactive interface that enables them to navigate the website with ease. On the other hand, tablet users will be presented with an appropriately sized navigation whilst desktop users will be presented with a glorious drop-down navigation menu.

The whole point of web design is to present appropriate user interfaces that feel native to the user’s environment. Due to the rising number of users from mobile and tablet devices, the “Responsive Web Design” approach has become a necessity in modern day web design. There is a new commandment in web design practice: Thou shalt not discriminate against devices.</p><p>The post <a href="http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/">Building a Responsive, Mobile-First Navigation Menu</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>This tutorial will demonstrate how to develop a rather complex responsive navigation menu using the &#8220;<a title="Mobile First Web Design" href="http://bradfrostweb.com/blog/web/mobile-first-responsive-web-design/">Mobile-First Approach</a>&#8220;. The aim is to present mobile users with a pseudo-native, touch-conducive and interactive interface that enables them to navigate the website with ease. Tablet users will be presented with an appropriately-sized navigation whilst desktop users will be presented with a glorious drop-down navigation menu.</p>
<p>The whole point of the practice of web design is to present appropriate user interfaces that feel native to the users&#8217; environment. Due to the rising number of users from mobile and tablet devices, the &#8220;<a title="Responsive Web Design - A List Apart" href="http://www.alistapart.com/articles/responsive-web-design/">Responsive Web Design</a>&#8221; approach has become a necessity in modern day web design. There is a new commandment in web design practice: Thou shall not discriminate against devices.</p>
<p>I have written a hands-on tutorial using the Progressive Enhancement technique regarding the design and development of a “<a title="Bulletproof Dropdown Navigation Menu with CSS3" href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/" target="_blank">Bulletproof Navigation Menu</a>” that works across all major browsers. But nowadays more and more people are browsing the internet with mobile devices and as a result, the  existing techniques of web development &#8211; as demonstrated in my tutorial &#8211; have become archaic and produces very unpleasant experiences for mobile users.</p>
<h2>Demonstration</h2>
<div id="attachment_806" class="wp-caption alignnone" style="width: 690px"><a href="http://azadcreative.com/demo/responsive-nav/" target="_blank"><img class=" wp-image-806  " title="Click to Open Demonstration in a New Window" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2012/06/Hero.jpg?resize=680%2C340" alt="Responsive Navigation Menu" data-recalc-dims="1" /></a><p class="wp-caption-text">Responsive Navigation Menu – Click to Open Demonstration</p></div>
<p>The solution presented here is, by no means, ideal for developing complex navigation menus, is not without limitations and should not be copied wholesale into a production environment. This is a proof-of-concept that attempts to achieve that following:</p>
<ul>
<li>Mobile-first approach for development. Start with the smallest resolution and build upwards.</li>
<li>Provide a (somewhat) native User Experience for users of mobile devices.</li>
<li>Provide a complete desktop experience when browsed on large devices.</li>
</ul>
<p>A slight warning about the demo: If you are going to stretch the corner of your browser to test how it “responds”, you may be disappointed. <span class="highlight">It is recommended that you reload the page after you have resized your viewport.</span></p>
<p>If you are keen on trying out the demonstration in your mobile device, use this shortlink:</p>
<p style="text-align: center;"><a href="http://bit.ly/respnav"><strong>http://bit.ly/respnav</strong></a></p>
<p>The code is “<a href="https://github.com/azadcreative/Responsive-Dropdown-Navigation-Menu" target="_blank">available at Github</a>” for your forking pleasure. You can also “<a href="https://github.com/azadcreative/Responsive-Dropdown-Navigation-Menu/zipball/master" target="_blank">download the source code</a>” and play around.</p>
<h2>Existing Responsive Navigation Patterns</h2>
<p>The navigation happens to be the most important aspect of any website and it is important to provide appropriate navigability for users on any website regardless of the device they are browsing from. The problem with existing web design practice is that the content is not optimised and difficult to navigate on mobile devices.</p>
<p>Expert practitioners have extensively written about Responsive Web Design; patterns, best practices and what not. Some notable insights into responsive navigation design patterns are:</p>
<ul>
<li>Brad Frost&#8217;s article about “<a title="Responsive Navigation Patterns" href="http://bradfrostweb.com/blog/web/responsive-nav-patterns/" target="_blank">Responsive Navigation Patterns</a>“ which provides excellent insight into the various methods of implementing responsive navigation menus.</li>
<li>Michael Mesker of Palantir provides a real-life case study and insight into responsive design in the article “<a title="Scalable Navigation Patterns in Responsive Web Design" href="http://www.palantir.net/blog/scalable-navigation-patterns-responsive-web-design" target="_blank">Scalable Navigation Patterns in Responsive Web Design</a>“.</li>
</ul>
<p>In the aforelinked article, I found this little sentence very intriguing:</p>
<blockquote>
<div>Navigation patterns for RWD is exciting territory that we as an industry are all still exploring.</div>
<div>- Micheal Mesker.</div>
</blockquote>
<p>The most popular solution to navigation design is, by far, the “select menu” approach, where the navigation is displayed as a <span class="highlight">select menu</span> or <span class="highlight">dropdown menu</span> on smaller viewports. There is a plethora of javascript libraries available for converting navigation menus to drop-downs on small screens. Some of the tools used by developers for converting their existing design to responsive are as follows:</p>
<ul>
<li>Matt Everson of Astuteo authored <a title="Mobile Dropdown Conversion" href="http://astuteo.com/mobilemenu/">Mobile Dropdown Conversion</a>.</li>
<li>Viljami Salminen authored the &#8220;<a title="TinyNav" href="http://tinynav.viljamis.com/">TinyNav.js</a>&#8221; library.</li>
<li>Roger Johansson has recently published “<a href="http://www.456bereastreet.com/archive/201206/an_alternative_to_select_elements_as_navigation_in_narrow_viewports/" target="_blank">an alternative to the select element for smaller viewports</a>” where the user can toggle the menu with a button on mobile devices.</li>
</ul>
<p>Perhaps the reason for the popularity of this approach is that most developers are <em><span style="text-decoration: underline;">converting</span></em> their existing designs to adapt to the mobile viewports. This is quite the opposite of what we are trying to achieve with the mobile-first approach.</p>
<p>There are some notable hands-on tutorials that demonstrate the mobile-first approach for developing responsive navigation menus:</p>
<ul>
<li>Joshua Johanson has written a brilliant tutorial for DesignShack: “<a title="Code a Responsive Navigation Menu" href="http://designshack.net/articles/css/code-a-responsive-navigation-menu/" target="_blank">Code a Responsive Navigation Menu</a>“.</li>
<li>Jeremy Hixon’s piece at SmashingMag: “<a title="Progressive And Responsive Navigation" href="http://coding.smashingmagazine.com/2012/02/13/progressive-and-responsive-navigation/" target="_blank">Progressive And Responsive Navigation</a>“.</li>
<li>Nick La for WebDesignerWall authored &#8220;<a title="Mobile Navigation Design &amp; Tutorial" href="http://webdesignerwall.com/tutorials/mobile-navigation-design-tutorial">Mobile Navigation Design and Tutorial</a>&#8220;.</li>
<li>Filament Group posted their brilliant article &#8220;<a title="A Responsive Design Approach for Navigation" href="http://filamentgroup.com/lab/responsive_design_approach_for_navigation/">A Responsive Design Approach for Navigation</a>&#8220;.</li>
</ul>
<p>The existing solutions are commendable work by their respective authors but they also come with some limitations.</p>
<p>This tutorial will follow “the toggle” pattern (as classified by Brad Frost) for building a relatively complex website navigation. The development process will be entirely mobile-first and will attempt to deliver a very native user experience to all users regardless of the device resolution.</p>
<h2>Prerequisites</h2>
<p>If you are <a href="https://github.com/azadcreative/Responsive-Dropdown-Navigation-Menu">downloading the source from Github</a>, you can skip this section entirely. Please make sure that your local web server is fired up and the files are placed in your htdocs.</p>
<p>We are going to use fine blend of libraries and tools for development of this navigation menu. Before we get started with the development, please complete the following steps:</p>
<ol>
<li>Download the latest copy of <a title="Normalise.css" href="http://necolas.github.com/normalize.css/" target="_blank">Normalise.css</a>.</li>
<li>Download the latest <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a>, the latest <a title="Modernizr" href="http://modernizr.com" target="_blank">Modernizr</a> and <a title="Seletivizr" href="http://selectivizr.com/" target="_blank">Selectivizr</a>.</li>
<li>Download the <a title="HoverIntent" href="http://cherne.net/brian/resources/jquery.hoverIntent.html" target="_blank">HoverIntent</a> library.</li>
<li>Grab the latest <a title="Overthrow.js" href="https://github.com/filamentgroup/Overthrow/" target="_blank">Overthrow.js</a> from Filament Group.</li>
<li>Get an good understanding of <a href="http://t.co/dKP3o1e">Viewport and Device Width</a>, if you do not already.</li>
<li>Get your code editor fired up.</li>
</ol>
<p>Now setup a basic file and folder structure as per the following:</p>
<div id="attachment_807" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-807" title="The File Structure for the Demonstration" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2012/06/file-structure.jpg?resize=680%2C140" alt="The File Structure for the Demonstration" data-recalc-dims="1" /><p class="wp-caption-text">The File Structure for the Demonstration</p></div>
<p>Place the javascript libraries (jQuery, Modernizr and Selectivizr) into the <span class="highlight">js</span> folder. Also, place normalise.css in the <span class="highlight">css</span> folder. Now, we are set to go.</p>
<h2>Target Segments of the Audience</h2>
<p>The target audience will vary from project to project, depending on the business objectives of the website and the client funding it. But for the purpose of this demonstration, we have selected four broad target audiences.</p>
<p>Since we are building from small devices upwards towards larger screen sizes, here is the order of the segments of the audience we are going to cater for:</p>
<ol>
<li>Smartphones with a minimum device width of 320 pixels and a maximum device width of 480 pixels. This covers pretty much all smartphones out there.</li>
<li>Small tablet and mobile devices with a resolution between 481 and 767 pixels. This includes the 4+ inch phones and the small 7-inch tablets.</li>
<li>iPad specific stylesheet<sup><a id="identifier_0_803" title="Why iPad and not other tablet devices? Because at the time of writing, no other tablet matters." href="http://lamphost:8080/wordpress/?p=803#footnote_0_803">1</a></sup>, with a minimum device width of 768 and maximum of 1024, which defines rules that apply to both portrait and landscape orientations.</li>
<li>Desktop devices and anything larger.</li>
</ol>
<p>There is always the scope of further segmenting the Target Audiences. It is possible to design different layouts for portrait and landscape orientations and also for internet-enabled televisions. Some websites cater up to 6 segments using Media Queries. There is no rule of thumb or general guideline as to how many segments you should style for. The matter is entirely variable based on business requirements.</p>
<h2>The Markup</h2>
<p>Now that we know our target segments and have built the basic file structure, let us start with the markup.</p>
<h3>The &lt;head&gt;</h3>
<p>The code above borrows heavily from the &#8220;<a href="http://stuffandnonsense.co.uk/projects/320andup/">320 and Up Framework</a>&#8221; and some bits and pieces from &#8220;<a href="http://twitter.github.com/bootstrap/">Twitter Bootstrap</a>&#8221; as well as the &#8220;<a href="http://html5boilerplate.com/mobile">HTML5 Boilerplate Mobile</a>&#8220;. Unfortunately, all frameworks/boilerplates come with some useless cruft that is no good for this demonstration. So, instead of copying the boilerplates wholesale, we are only taking the useful bits and pieces.</p>
<pre>&lt;!doctype html&gt;
&lt;head&gt;
 &lt;meta charset="utf-8"&gt;

 &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;

 &lt;title&gt;Responsive Navigation Menu&lt;/title&gt;
 &lt;meta name="description" content="A hands-on tutorial on how to build an advanced Responsive Navigation Menu."&gt;
 &lt;meta name="author" content="Saddam Azad - UI Designer and Front-end Web Developer. London, UK."&gt;

 &lt;!-- http://t.co/dKP3o1e --&gt;
 &lt;meta name="HandheldFriendly" content="True"&gt;
 &lt;meta name="MobileOptimized" content="320"&gt;
 &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"&gt;

 &lt;link rel="shortcut icon" href="/favicon.ico"&gt;

 &lt;!-- For all browsers --&gt;
 &lt;link href='http://fonts.googleapis.com/css?family=Euphoria+Script|Lato' rel='stylesheet' type='text/css'&gt;

 &lt;link rel="stylesheet" href="css/normalise.css" media="screen"&gt;
 &lt;link rel="stylesheet" href="css/atmosphere.css" media="screen"&gt;

 &lt;!-- Media Queries --&gt;
 &lt;link rel="stylesheet" href="css/mobile-nav.css" media="screen and (min-width: 320px) and (max-width: 1024px)"&gt;

 &lt;link rel="stylesheet" href="css/smartphone.css" media="screen and (min-width:320px) and (max-width:480px)"&gt;
 &lt;link rel="stylesheet" href="css/tablet.css" media="screen and (min-width: 481px) and (max-width: 767px)"&gt;
 &lt;link rel="stylesheet" href="css/ipad.css" media="screen and (min-width: 768px) and (max-width: 1024px)"&gt;

 &lt;link rel="stylesheet" href="css/desktop.css" media="screen and (min-width: 1025px)"&gt;

 &lt;!--[if lt IE 9]&gt;
 &lt;link rel="stylesheet" href="css/desktop.css" media="screen"&gt;
 &lt;![endif]--&gt;

 &lt;!--[if (lt IE 9) &amp; (!IEMobile)]&gt;
 &lt;script src="js/selectivizr-1.0.3.min.js"&gt;&lt;/script&gt;
 &lt;![endif]--&gt;
 &lt;script src="js/modernizr-2.5.3.min.js"&gt;&lt;/script&gt;

 &lt;meta http-equiv="cleartype" content="on"&gt;
&lt;/head&gt;</pre>
<p>Some of the notable pieces from this code are:</p>
<ul>
<li>The meta tags with attributes such as HandheldFriendly, MobileOptimised and &#8220;<a title="Viewport Meta Tag" href="http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/quick-tip-dont-forget-the-viewport-meta-tag/" target="_blank">Viewport</a>&#8220;.
<ul>
<li>These are “<a title="Mobile Meta Tags" href="http://learnthemobileweb.com/blog/2009/07/mobile-meta-tags/" target="_blank">Mobile Meta Tags</a>” that are quite essential for developing for mobile devices.</li>
<li>The “<a title="Complete Idiot's Guide to Viewport and Media Queries" href="http://t.co/dKP3o1e" target="_blank">Complete Idiot’s Guide to Viewport and Media Queries</a>” may shed some light if you are in the dark.</li>
<li>The markup documentation for “<a title="HTML5 Boilerplate Docs" href="https://github.com/h5bp/mobile-boilerplate/wiki/The-Markup" target="_blank">HTML5 Boilerplate</a>” provides a far better insight into these meta tags.</li>
</ul>
</li>
<li>For the purpose of this tutorial, we are going to add a link to Google Webfonts to retrieve the fonts  ”<a title="Euphoria Script - Google Web Fonts" href="http://www.google.com/webfonts/specimen/Euphoria+Script" target="_blank">Euphoria Script</a>“ and “<a title="Lato - Google Web Fonts" href="http://www.google.com/webfonts/specimen/Lato" target="_blank">Lato</a>“. This step is entirely optional.</li>
<li>And then we are going to use a <del>modified</del> bastardised version of Andy Clarke’s “<a href="http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries" target="_blank">Hardboiled CSS3 Media Queries</a>” for the purpose of linking our stylesheets.</li>
</ul>
<p>The reason for separating the stylesheets is because adding so many Media Queries within one stylesheet is perhaps not the best idea, in my opinion. This is actually quite a controversial issue and purely a matter of preference and/or situational requirement. I personally prefer the external stylesheets and I believe it serves the purpose of this tutorial better. Zoe Gillenwater has written comprehensive pros and cons for “<a href="http://zomigi.com/blog/essential-considerations-for-crafting-quality-media-queries/#mq-embed-external" target="_blank">external vs. embedded media queries</a>” that is a must-read.</p>
<p>But why so many stylesheets? Here’s why:</p>
<ol>
<li>The first stylesheet is a query to Google Web Fonts for “<a title="Euphoria Script - Google Web Fonts" href="http://www.google.com/webfonts/specimen/Euphoria+Script" target="_blank">Euphoria Script</a>“ and “<a title="Lato - Google Web Fonts" href="http://www.google.com/webfonts/specimen/Lato" target="_blank">Lato</a>“ fonts.</li>
<li>The <span class="highlight">normalise.css</span> is the alternative to reset.css that is much better suited for modern web design.</li>
<li>The <span class="highlight">atmosphere.css</span> is the colour, texture and typography separated from the layout and media-specific code.</li>
<li>The first of the Media Queries, <span class="highlight">mobile-nav.css</span>, defines a broad resolution window (between 320 pixels and 1024 pixels). This is the common code that would be applicable to a large range of devices &#8211; from phones to tablets. Hence, instead of replicating the code, we are creating a separate stylesheet.</li>
<li>The <span class="highlight">smartphone.css</span> targets devices between a width of 320 and 480 pixels, as defined in our list of Target Audiences.</li>
<li>The following is <span class="highlight">tablet.css</span> which accounts for #2 on the Target Audience list: tablets (and large phones) between the resolutions 481 and 767 pixels.</li>
<li>Next comes the <span class="highlight">ipad.css</span>. With this stylesheet, we will cover both the portrait and landscape orientations.</li>
<li>The next one is the <span class="highlight">desktop.css</span> for screens larger than 1025 pixels.</li>
<li>Since Internet Explorer 8 and below do not support Media Queries, we are going to tell older IE versions to accept desktop.css as the default stylesheet through conditional comments.</li>
</ol>
<p>Once the Media Queries are set up, there are some other interesting bits in the &lt;head&gt;:</p>
<ul>
<li>We will have to embed Selectivizr for Internet Explorer 8 and below.</li>
<li>Embed Modernizr for all browsers.</li>
<li>Lastly, we have added a meta tag to activate cleartype rendering in Mobile IE for smooth font rendering.</li>
</ul>
<h3>The &lt;body&gt;</h3>
<p>Now that we’re done with the head, let us build the essential bits of the body. Within the header element, we have set up the branding and tagline as headings.</p>
<pre>&lt;body&gt;
&lt;header role="banner"&gt;
  &lt;h1 id="branding"&gt;&lt;a href="#"&gt;Responsive Navigation&lt;/a&gt;&lt;/h1&gt;
  &lt;h2 id="tagline"&gt;A beautifully crafted responsive navigation menu&lt;/h2&gt;

  &lt;nav&gt;

    &lt;a class="btn btn-navbar" data-toggle="collapse"&gt;
      &lt;span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;/span&gt;
      &lt;span&gt;&lt;/span&gt;
    &lt;/a&gt;

    &lt;ul id="menu" class="overthrow"&gt;
    ...
    &lt;/ul&gt;

  &lt;/nav&gt;
&lt;/header&gt;</pre>
<p>After the branding and tagline comes the most crucial <span class="highlight">nav</span> element and there are two components within:</p>
<ol>
<li>An anchor with class <span class="highlight">btn</span> — and within it lies three span elements. This bit of the code is borrowed from the “<a title="Bootstrap Navbar Component" href="http://twitter.github.com/bootstrap/components.html#navbar" target="_blank">Navbar Component</a>” of the <a title="Twitter Bootstrap framework" href="http://twitter.github.com/bootstrap/" target="_blank">Bootstrap framework</a>.</li>
<li>An unordered list called ‘menu’. The list items would be enclosed within the unordered list but they are not demonstrated here for the sake of clarity.<sup><a href="http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/#footnote_0_805" id="identifier_0_805" class="footnote-link footnote-identifier-link" title="It is worth mentioning that the markup of the menu remains exactly the same as &ldquo;Bulletproof Navigation Menu&rdquo; tutorial I authored in January 2012.">1</a></sup> Get the whole <a href="https://github.com/azadcreative/Responsive-Dropdown-Navigation-Menu/blob/master/index.html">markup from Github</a>.</li>
<li>Note that the menu contains a classname of ‘overthrow’. This is a requirement of Overthrow.js as it enables greater support on mobile devices (using pollyfills where necessary and graceful degradation when not supported).</li>
</ol>
<p>Apart from the header element, there are space fillers such as a section element with some content and a footer element with credits. These are non-essential for the tutorial.</p>
<div>
<p>Before we skip to the stylesheets, let us have a look at the bottom part of the html document.</p>
<pre>&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;window.jQuery || document.write('&lt;script src="js/jquery-1.7.2.min.js"&gt;&lt;\/script&gt;')&lt;/script&gt;

&lt;script src="js/plugins.js"&gt;&lt;/script&gt;
&lt;script src="js/helper.js"&gt;&lt;/script&gt;
&lt;script src="js/script.js"&gt;&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
</div>
<p>As you can see, there are quite a few javascript files being linked to:</p>
<ul>
<li>Firstly, it is a call to the Google CDN for the jQuery library. In the event that jQuert fails to load from the CDN, it will be found within the ‘js’ folder of our structure.</li>
<li>The <span class="highlight">plugins.js</span> file is borrowed from the HTML5 Boilerplate and can be found in the “<a href="https://github.com/h5bp/html5-boilerplate/blob/master/js/plugins.js" target="_blank">Github repo</a>“.
<ul>
<li>It is recommended that you append all additional jQuery libraries with this file.  It would save us an additional HTTP request for each library and keep all the libraries in one place.</li>
<li>Append the “<a title="jQuery HoverIntent" href="http://cherne.net/brian/resources/jquery.hoverIntent.html" target="_blank">HoverIntent</a>” library.</li>
<li>Append “<a title="Overthrow.js" href="http://filamentgroup.github.com/Overthrow/" target="_blank">Overthrow.js</a>” as well.</li>
</ul>
</li>
<li>The <span class="highlight">helper.js is</span> borrowed from the <a href="https://github.com/h5bp/mobile-boilerplate/blob/master/js/helper.js" target="_blank">Mobile Boilerplate</a>.</li>
<li>The <span class="highlight">script.js</span> will be a blank document for now but we are going to need it later.</li>
</ul>
<h2>The Stylesheets: Atmosphere</h2>
<p>Now that our markup structure is complete, let us move on to the stylesheets. Apart from the link to Google Web Fonts, the next stylesheet embedded into our document is <span class="highlight">normalise.css</span>.</p>
<p>The following stylesheet is the <span class="highlight">atmosphere.css</span>. There are bits of the CSS styling that apply to elements regardless of the resolution. An example would the background-image of the document. The colour, texture and typography remain constant across all devices. This is aptly-named as the “atmosphere” of the design by <a href="http://stuffandnonsense.co.uk">Andy Clarke</a>, the author of <a href="http://stuffandnonsense.co.uk/projects/320andup/">320-and-Up</a>.</p>
<pre>/* The clearfix method */
.clearfix {
  *zoom: 1;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}</pre>
<p>First up, we have the “<a href="http://stackoverflow.com/questions/211383/which-method-of-clearfix-is-best" target="_blank">CSS Clearfix method</a>” which allows us to clear floated elements with ease.</p>
<pre>/* Basic Styling of the Body */
body {
  background: #e0e0e0 url(/demo/responsive-nav/img/background.png);
  margin: 0 auto;
  color: black;
  text-align: center;
  font-family: "Lato", Helvetica, Arial, sans-serif;
  font-weight: 300 !important;
  font-size: 10px;
  position: relative;
  overflow: auto;
  max-width: 1300px;
}
a:link,
a:visited {
  color: #666;
  text-decoration: underline;
}
a:hover,
a:active {
  color: #a67b45;
  text-decoration: none;
  outline: none;
}
a:active {
  color: #ff6000;
}</pre>
<p>When styling the body, we are:</p>
<ul>
<li>Using a background pattern that can be repeated.</li>
<li>Making <span class="highlight">Lato</span> the default font, and falling back to Helvetica/Arial when Google Web Fonts cannot be loaded.</li>
<li>Setting the default font size to 10px. Alternatively, you can use the &#8220;<a href="http://clagnut.com/blog/348/">62.5% technique</a>&#8220;.</li>
<li>Setting the max-width to 1300 pixels.</li>
</ul>
<pre>/* Le Header */
header {
  padding: 20px 0;
  position: relative;
}
header h1#branding a {
  font-family: "Euphoria Script", cursive;
  font-weight: normal;
}
header h1#branding a:link,
header h1#branding a:visited {
  color: #000;
  text-decoration: none;
}
header h1#branding a:hover,
header h1#branding a:active {
  color: #a67b45;
  text-decoration: none;
}
header h2#tagline {
  text-align: center;
  font-size: 1em;
  font-weight: normal;
  text-transform: uppercase;
  color: #444;
}</pre>
<p>Next, we are styling the header element.</p>
<ul>
<li>The branding is using the fantastic Euphoria Script font from Google Web Fonts. Falls back to any cursive font that is default on the system.</li>
<li>Making the tagline uppercase and aligning to the center of the screen. This will remain consistent across all viewports.</li>
</ul>
<pre>/* The common properties in the NAV element */
header nav {
  background-color: #f8f8f8;
  background-image: -moz-linear-gradient(top, #ffffff, #ededed);
  background-image: -ms-linear-gradient(top, #ffffff, #ededed);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#ededed));
  background-image: -webkit-linear-gradient(top, #ffffff, #ededed);
  background-image: -o-linear-gradient(top, #ffffff, #ededed);
  background-image: linear-gradient(top, #ffffff, #ededed);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0);
  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-family: "Lato", Helvetica, Arial, sans-serif;
  font-size: 1.5em;
}

/* Making sure lists have no margin/padding */
header ul#menu {
  margin: 0 !important;
  padding: 0 !important;
}</pre>
<p>This is the crucial navigation bar. Over here, we are defining the basic style of the navigation bar that will be applicable to both the mobile and desktop resolutions. We are also using vendor-specific code for <a title="CSS3 Gradients" href="http://css-tricks.com/css3-gradients/" target="_blank">CSS3 Gradients</a> and <a href="http://css-tricks.com/snippets/css/css-box-shadow/" target="_blank">Box Shadow</a>.</p>
<pre>/* The content and footer sections */
section.content,
footer {
  padding: 10px 20px;
  background: #FFF;
  font-size: 1.5em;
  line-height: 1.5em;
  text-align: left;
  -webkit-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
  -moz-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
  box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
}
footer {
  margin: 20px 0;
}</pre>
<p>Over here, we are styling the content box and the footer. The code should be self-explanatory.</p>
<h2>The Stylesheets: Navigation Menu for Mobile Devices</h2>
<p>Here is what we are trying to accomplish:</p>
<div id="attachment_808" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-808" title="Navigation Bar for Mobile Devices" src="http://i0.wp.com/azadcreative.com/wp-content/uploads/2012/07/Mobile-Nav.jpg?resize=680%2C231" alt="Navigation Bar for Mobile Devices" data-recalc-dims="1" /><p class="wp-caption-text">Navigation Bar for Mobile Devices</p></div>
<p>Now that the basic CSS bits are done, let us move on to the CSS Media Queries.  The first CSS attached to the document that is using the Media Queries is the <span class="highlight">mobile-nav.css</span> that is applicable to devices with widths between 320 and 1024 pixels. This stylesheet applies to a very broad spectrum of devices ranging from smartphones to iPads.</p>
<p>I have previously mentioned that this bit of code will be used by at least three of the target segments of the audience. So, instead of repeating the CSS, we are delegating it to a separate stylesheet document.</p>
<pre>/* The NAV element in mobile devices */
header nav {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  zoom: 1;
  width: auto;
  text-align: left;
  height: 40px;
  width: 100%;
}</pre>
<p>The nav element is given a fixed position on top the viewport so that it remains in place even when you scroll the page.</p>
<pre>/* The button on the top-right */
nav .btn-navbar {
  position: fixed;
  right: 10px;
  top: 6px;
  padding: 7px 10px;
  margin-left: 5px;
  margin-right: 5px;
  -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075);
  -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.075);
}
nav .btn-navbar:active {
  background-color: #e6e6e6;
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#d9d9d9), to(#ffffff));
  background-image: -webkit-linear-gradient(top, #ffffff, #d9d9d9);
  background-color: #d9d9d9;
  background-image: -moz-linear-gradient(top, #d9d9d9, #ffffff);
  background-image: -ms-linear-gradient(top, #d9d9d9, #ffffff);
  background-image: -o-linear-gradient(top, #d9d9d9, #ffffff);
  background-image: linear-gradient(top, #d9d9d9, #ffffff);
  background-repeat: repeat-x;
}
nav .btn-navbar .icon-bar {
  display: block;
  width: 18px;
  height: 2px;
  background-color: #000;
  -webkit-border-radius: 1px;
  -moz-border-radius: 1px;
  border-radius: 1px;
  -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
nav .btn-navbar.active .icon-bar {
  background-color: #a67b45;
  -webkit-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
  -moz-box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.25);
}
.btn-navbar .icon-bar + .icon-bar {
  margin-top: 3px;
}</pre>
<p>The button on the top-right corner is given a fixed position and sprinkled with some CSS3 Inset Box Shadow for looks. The <span class="highlight">icon-bar</span> elements are designed to emulate the look of native buttons. This bit of the code is borrowed from Bootstrap and modified to fit the needs.</p>
<p>Next up, we are going to style the navigation menu itself. The menu would reveal itself when the top-right button is clicked/touched. However, before we get into the behaviour manipulation with Javascript, let us style the menu.</p>
<pre>/* Using the touch scrolling on capable devices. */
.overthrow-enabled .overthrow {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}</pre>
<p>A noticeable line in the code is the <span class="highlight">-webkit-overflow-scrolling: touch;</span>. This is for &#8220;<a href="http://johanbrook.com/browsers/native-momentum-scrolling-ios-5/">Native Momentum Scrolling</a>&#8221; on iOS devices.<sup><a href="http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/#footnote_1_805" id="identifier_1_805" class="footnote-link footnote-identifier-link" title="Thanks to&nbsp;Johan Brook">2</a></sup></p>
<p>We are taking advantage of the Overthrow library that enables overflow scrolling on few devices using a polyfill and gracefully degrades on non-supporting devices.</p>
<pre>/* The unordered list with the menu */
ul#menu {
  background: #000;
  display: none;
  position: absolute;
  top: 40px;
  left: 0;
  width: 100%;
  font-size: 15px !important;
  overflow-x: hidden;
  -ms-overflow-x: hidden;
  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
ul#menu li {
  display: block;
  height: 40px;
  width: 100%;
  border-bottom: 1px solid #ccc;
  background-color: #ededed;
  background-repeat: repeat-x;
  background-image: -moz-linear-gradient(top, #ffffff, #ededed);
  background-image: -ms-linear-gradient(top, #ffffff, #ededed);
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #ededed));
  background-image: -webkit-linear-gradient(top, #ffffff, #ededed);
  background-image: -o-linear-gradient(top, #ffffff, #ededed);
  background-image: linear-gradient(top, #ffffff, #ededed);
  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0);
}
ul#menu li:last-child {
  border: none;
}
ul#menu li.hasChildren {
  height: auto !important;
}
ul#menu li.hasChildren ul {
  display: none;
  margin: 0 !important;
  padding: 0 0 0 20px !important;
}
ul#menu li.hasChildren ul li {
  background: none;
}
ul#menu li a {
  display: block;
  text-decoration: none;
  padding: 12px 10px;
  font-weight: normal;
}
ul#menu li a span {
  display: block;
}
ul#menu li a:link,
ul#menu li a:visited {
  color: #666;
  text-decoration: none;
  outline: none;
}
ul#menu li a:hover,
ul#menu li a:active {
  color: #a67b45;
  text-decoration: none;
  outline: none;
  background: rgba(0, 0, 0, 0.05);
}
ul#menu li.hasChildren a &gt; span {
  background: url(/demo/responsive-nav/img/sprite.png);
  background-position: right -97px !important;
  background-repeat: no-repeat;
}
ul#menu li.hasChildren a:hover &gt; span,
ul#menu li.hasChildren.hover &gt; a span {
  background-position: right -138px !important;
}</pre>
<p>The menu itself is a quite simple dropdown. A few noteworthy bits of the code are:</p>
<ul>
<li>The menu is positioned just below the bar.</li>
<li>The menu takes 100% of the width of the viewport.</li>
<li>Due to the fact that, in some devices, a horizontal scrollbar appears, we have used <span class="highlight">overflow-x: hidden</span>;  and its Mobile IE counterpart.</li>
<li>The list items have CSS3 Gradients that is supported by most modern mobile browsers. Otherwise, it falls back to a light shade of grey.</li>
</ul>
<p>All is done with the mobile navigation. But a few problems remain:</p>
<ul>
<li>The menu requires a fixed height for the overflow scroll to work. But how do you apply a fixed height on a menu that can vary in height?</li>
<li>We have styled the navigation menu, but how do we make it appear on screen?</li>
</ul>
<p>The answer to both is: Javascript, of course.</p>
<h2>The Javascript: Behaviour Layer that does the Magic</h2>
<p>After the javascript behaviour is applied, here is what it should look like on mobile devices:</p>
<div>
<div id="attachment_809" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-809" title="Expanded View of the Navigation" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2012/07/Expanded.jpg?resize=680%2C330" alt="Expanded View of the Navigation" data-recalc-dims="1" /><p class="wp-caption-text">Interactive Button and Expanded View of the Navigation</p></div>
</div>
<p>All custom Javascript code is going into the <span class="highlight">script.js</span> file.</p>
<p>We are going to reuse the jQuery plugin developed for the &#8220;<a title="Bulletproof CSS3 Dropdown Navigation Menu" href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/">Bulletproof CSS3 Dropdown Navigation Menu</a>&#8221; as it is essential for both the desktop and mobile navigation layouts. Here is the custom plugin once again, for your convenience:</p>
<pre>/*
* jquery.dropdown.js
* Apply sexy dropdowns on any ul with child ul.
* Depends on: jquery.hoverIntent.js
*/

$.fn.dropdown = function(options) {
var defaults = {};
  var opts = $.extend(defaults, options);

  // Apply on those items with children
  this.each(function() {
    $(this).find('li').each(function() {
      if($(this).find("ul").length &gt; 0) {
        $(this).addClass("hasChildren");
        $(this).find('&gt; a').wrapInner("&lt;span&gt;&lt;/span&gt;");
      }
    });
  });

  // Apply on all list items
  $(this).find("li").on('hover', function() {
    $(this).addClass('hover');
  }, function() {
    $(this).removeClass('hover');
  });
};</pre>
<p>Here is what the plugin accomplishes:</p>
<ul>
<li>Find the list items with children, adds the class &#8216;hasChildren&#8217; and also adds a <span class="highlight">span</span> to wrap the anchor for styling purposes.</li>
<li>Adds the class &#8216;hover&#8217; when the list items are hovered upon.</li>
</ul>
<p>Now that the plugin is done, let us go further into the script.</p>
<pre>$(function() {

  // Calling the jquery dropdown
  $('nav').dropdown();

  /*
  * Applicable only to Mobile-nav
  */

  // Checking if the top-right button is visible.
  if ($("nav a.btn-navbar").is(":visible")) {

    // Making the dropdown magically appear onclick/touch.
    $('nav a.btn-navbar').on('click', function() {
      $('ul#menu').slideToggle('fast', function() {
        $('ul#menu').css({

        // The height must be fixed for the native-scrolling on iOS
        'height': $(this).height(),

        // But we don't want the height of the nav to exceed the viewport.
        'max-height': $(window).height() + 20
        });
      });

      $(this).toggleClass('active');

    }); // end on.click

    // Making the children appear on click/touch
    $('ul#menu li.hasChildren a').on('click', function() {
      $(this).parent().children('ul').slideToggle('fast', function() {

          $('ul#menu').css({

          // Resetting the height to auto in order to expand/contract the menu upon interaction.
          'height': 'auto',

          // But we don't want the height of the nav to exceed the viewport.
          'max-height': $(window).height() + 20
          });

        }); // end slideToggle
    }); // end on.click

 } // end visibility check

});</pre>
<p>The code above accomplishes the following:</p>
<ul>
<li>Firstly, we are calling the jQuery function that was provided a little earlier onto the nav element.</li>
<li>Checking to see if the <span class="highlight">btn-navbar</span>is visible on screen. If it is visible, it would mean that the mobile-nav is active.<sup><a href="http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/#footnote_2_805" id="identifier_2_805" class="footnote-link footnote-identifier-link" title="I am sure there is a better method of checking whether the viewport is small enough for the mobile-nav to be active. I am open to suggestions.">3</a></sup>
<ul>
<li>Once it is established that the mobile-nav is indeed what the user is experiencing, there is a &#8216;click&#8217; event on the button that toggles the unordered list.</li>
<li>Once the animation for slideToggle is complete, we are defining the height of the menu. This is because native-scrolling on iOS devices only work on objects with a fixed height.</li>
<li>Next, we are ensuring that the height of the menu does not exceed the viewport by setting a max-height.</li>
<li>Next up, there is another &#8216;click&#8217; event that makes sure the list items with children can expand and contract on click/touch.</li>
<li>The height of the entire menu is reset once the user expands/contracts a list item.</li>
</ul>
</li>
</ul>
<p>With this layer of Javascript, we now have a complete navigation menu &#8211; completely optimised for the mobile viewport.</p>
<h2>The Stylesheets: Smartphones</h2>
<p>This is what the mobile navigation will look like in smartphones:</p>
<div id="attachment_810" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-810" title="Responsive Navigation in a Smartphone" src="http://i0.wp.com/azadcreative.com/wp-content/uploads/2012/07/Smartphone.jpg?resize=680%2C600" alt="Responsive Navigation in a Smartphone" data-recalc-dims="1" /><p class="wp-caption-text">Responsive Navigation in a Smartphone</p></div>
<p>The smartphones with a horizontal resolution between 320 and 480 pixels will be provided with a few unique interface features such as:</p>
<div>
<ul>
<li>The branding will be a part of the floating navigation bar at the top.</li>
<li>The tagline will be larger and vertically spaced between the navigation and the content.</li>
<li>The content will have a high line-height, in order to enhance readability.</li>
</ul>
</div>
<pre>header h1#branding {
  position: fixed;
  top: -15px;
  left: 10px;
  font-size: 2.5em;
  z-index: 1000;
}

header h2#tagline {
  font-size: 2em;
  line-height: 1.5em;
  margin: 40px 0 0 0;
}

section.content p {
  line-height: 2em;
}</pre>
<p>This concludes the content of <span class="highlight">smartphone.css</span>.</p>
<div>
<h2>The Stylesheets: Small Tablets and the iPad</h2>
<p>Here is what it looks like on iPad and other tablets:</p>
<div>
<div id="attachment_812" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-812" title="Responsive Navigation Menu on iPad" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2012/07/iPad.jpg?resize=680%2C471" alt="Responsive Navigation Menu on iPad (in Portrait Orientation)" data-recalc-dims="1" /><p class="wp-caption-text">Responsive Navigation Menu on iPad (in Portrait Orientation)</p></div>
<p>The stylesheets <span class="highlight">tablet.css</span> and <span class="highlight">ipad.css</span> covers the device in both portrait and landscape orientations as we have not stipulated any orientation in the Media Queries. As there is litte difference between <span class="highlight">tablet.css</span> and <span class="highlight">ipad.css</span>, I have not repeated the code:</p>
<pre>header h1#branding {
  font-size: 4em;
  z-index: 1000;
  margin: 40px 0 0 0;
}
header h2#tagline {
  font-size: 1.7em;
  margin: 15px 0 5px 0;
}</pre>
<p>On tablet devices, the logo is much larger and positioned below the navigation bar. The tagline is positioned below the logo. However, on smaller tablets, the line-height of the text is slightly larger in order to increase readability:</p>
<pre>section.content p {
 line-height: 1.8em;
 }</pre>
<p>If you have a sidebar in your design, maybe you would like to have it placed at the bottom of the content in <span class="highlight">tablet.css</span>. On the other hand, the sidebar can be placed on the right hand side on the iPad. The structure of the stylesheets allows us to craft variations in the design.</p>
<div>
<h2>The Stylesheets: Desktop</h2>
<p>Our final target segment of the audience is the desktop. These are users with viewports of horizontal resolution of 1025 pixels or higher. This covers almost all modern laptops, desktops and internet-plugged televisions.</p>
<p>Here is what the desktop users experience:</p>
<div>
<div id="attachment_813" class="wp-caption alignnone" style="width: 690px"><img class="size-full wp-image-813" title="Responsive Navigation on Desktop and Larger Devices" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2012/07/Desktop.jpg?resize=680%2C525" alt="Responsive Navigation on Desktop and Larger Devices" data-recalc-dims="1" /><p class="wp-caption-text">Responsive Navigation on Desktop and Larger Devices</p></div>
</div>
<p>The navigation presented to desktop users is vastly different from the mobile experience. This is a very common suckerfish navigation menu that desktop users are very much accustomed to.</p>
<p>The code below is vastly similar to the &#8220;<a title="Bulletproof CSS3 Dropdown Navigation Menu" href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/">Bulletproof CSS3 Dropdown Navigation Menu</a>&#8221; tutorial I published in January 2012.</p>
<pre>html {
  overflow: hidden;
}
.btn-navbar {
  display: none;
}
header {
  margin: 0 auto 20px auto;
  padding: 0 5px;
}</pre>
<p>Firstly, we take care of the horizontal scrolling problem in older versions of IE with <span class="highlight">overflow: hidden</span> applied to the html element. Next, we make sure the top-right button does not appear on desktop screens. Also, we place the header in the center of the screen using margins.</p>
<pre>header h1#branding {
  font-size: 4em;
  margin: 10px 0 0 0;
}
header h2#tagline {
  font-size: 1.7em;
  margin: 15px 0 5px 0;
}
section,
footer {
  margin: 20px 5px;
}</pre>
<p>The branding is given an appropriate size and aligned appropriately. The position and size of the tagline is also adjusted. Now let us get to the tasty navigation part.</p>
<pre>nav {
  *zoom: 1;
  margin: 20px auto 0 auto;
  width: auto;
  text-align: left;
}
nav:before,
nav:after {
  display: table;
  content: "";
}
nav:after {
  clear: both;
}</pre>
<p>Keeping in mind that the nav element would inherit some styles (such as gradient and font) from atmosphere.css, we can march on with the design on the desktop. The navigation is aligned to the center of the screen. We are also applying the <span class="highlight">:before</span> and <span class="highlight">:after</span> pseudo-class clearing technique.</p>
<pre>nav ul {
  float: left;
  *zoom: 1;
  width: auto;
  z-index: 100;
  font-size: 15px;
  border-right: 1px solid #e8e8e8;
}
nav ul:before,
nav ul:after {
  display: table;
  content: "";
}
nav ul:after {
  clear: both;
}</pre>
<p>The font-size on the primary-level list is set in pixels because <span class="highlight">em</span> makes the children inherit relative styles, making the whole design inconsistent. Hence, going forward with a pixel-based size suites best.</p>
<pre>nav ul li {
  float: left;
  padding: 0 0 10px 0;
  position: relative;
  outline: none;
  line-height: 1.2em;
  padding: 0 1px 0 0;
  border-left: 1px solid #e8e8e8;
  list-style: none;
}
nav ul li.hasChildren a span {
  padding: 0 20px 0 0;
  background: url(/demo/responsive-nav/img/sprite.png);
  background-position: right top;
  background-repeat: no-repeat;
  display: block;
}
nav ul li.hasChildren a:hover span,
nav ul li.hasChildren.hover a span {
  background-position: right -50px;
}</pre>
<p>The list items are floated to the left and positioned as you would find in a regular suckerfish dropdown navigation. The items that have nested lists are given the class &#8220;hasChildren&#8221; by the javascript library are now being styled.</p>
<pre>nav ul a {
  padding: 15px 20px 15px 20px;
  font-weight: normal;
  float: left;
  display: block;
  zoom: 1;
}
nav ul a:link,
nav ul a:visited {
  color: #666;
  text-decoration: none;
  background-color: #f8f8f8;
  background-image: -moz-linear-gradient(top, #ffffff, #ededed);
  background-image: -ms-linear-gradient(top, #ffffff, #ededed);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#ededed));
  background-image: -webkit-linear-gradient(top, #ffffff, #ededed);
  background-image: -o-linear-gradient(top, #ffffff, #ededed);
  background-image: linear-gradient(top, #ffffff, #ededed);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0);
  -webkit-transition: all 0.3s ease;
  -moz-transition: all 0.3s ease;
  -ms-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
  outline: none;
}
nav ul a:hover,
nav ul a:active {
  color: #a67b45;
  text-decoration: none;
  background-color: #f4f4f4;
  background-image: -moz-linear-gradient(top, #ededed, #ffffff);
  background-image: -ms-linear-gradient(top, #ededed, #ffffff);
  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ededed), to(#ffffff));
  background-image: -webkit-linear-gradient(top, #ededed, #ffffff);
  background-image: -o-linear-gradient(top, #ededed, #ffffff);
  background-image: linear-gradient(top, #ededed, #ffffff);
  background-repeat: repeat-x;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff', GradientType=0);
  -webkit-transition: all 0.1s ease;
  -moz-transition: all 0.1s ease;
  -ms-transition: all 0.1s ease;
  -o-transition: all 0.1s ease;
  transition: all 0.1s ease;
  outline: none;
}
nav ul a:active {
  -webkit-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
  -moz-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
  box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
}</pre>
<p>The anchor links are given CSS3 Gradient backgrounds. The :hover and <span class="highlight">:active</span> states have an inverted gradient. Also, the inset Box Shadow on the :active state gives the list items some visual depth.</p>
<div>
<pre>#menu li:hover &gt; ul {
  display: block;
}
#menu li:hover &gt; a {
  color: #a67b45;
}</pre>
</div>
<p>This is the &#8220;switch&#8221; that makes the nested list appear when you hover on an item. Since we are using Selectivizr in our document, we can safely apply <span class="highlight">:hover</span> pseudo-class on the list.</p>
<pre>nav li ul {
  display: none;
  margin: 0;
  position: absolute;
  top: 46px;
  left: 0px;
  width: 130px;
  border: none !important;
  padding: 2px;
  background: #999;
  z-index: 1000;
  *zoom: 1;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
}
nav li ul:before,
nav li ul:after {
  display: table;
  content: "";
}
nav li ul:after {
  clear: both;
}
nav li ul a {
  float: none;
}
nav li ul li {
  width: 130px;
  display: block;
  border-top: 1px solid #cfcfcf;
  border-left: none !important;
}
nav li ul li.hasChildren a &gt; span {
  background: url(/demo/responsive-nav/img/sprite.png);
  background-position: right -97px !important;
  background-repeat: no-repeat;
}
nav li ul li.hasChildren a:hover &gt; span,
nav li ul li.hasChildren.hover &gt; a span {
  background-position: right -138px !important;
}</pre>
<p>The code presented here is the CSS for the child lists. They are positioned in relation to their parent. The floats have been taken away from the list items and they are now block elements with a fixed width of 130 pixels.</p>
<pre>.rgba nav li &gt; ul {
  padding: 10px;
  left: -10px;
  background: rgba(0, 0, 0, 0.1);
  -webkit-border-radius: 10px;
  -moz-border-radius: 10px;
  border-radius: 10px;
}
nav li ul li ul {
  display: none;
  left: 130px !important;
  top: -3px;
}
.rgba nav li ul li ul {
  top: -10px;
}
.rgba nav li &gt; ul {
  margin-top: -1px;
}</pre>
<p>We are taking advantage of Modernizr to provide enhancements to the navigation on modern browsers. Browsers with <span class="highlight">rgba</span> support would be provided with a transparent rounded border around the dropdowns that creates a nice visual effect. Go ahead the read the “<a title="Bulletproof Dropdown Navigation Menu with CSS3" href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/" target="_blank">Bulletproof CSS3 Dropdown Navigation Menu</a>” article for a complete rundown on the development of this progressively enhanced menu.</p>
<p>That concludes the code for <span class="highlight">desktop.css</span>.</p>
<p>With that, we have concluded the development of the navigation menu using the mobile-first approach. Try out the &#8220;<a href="http://bit.ly/respnav">demonstration site</a>&#8221; and test using mobile/tablet devices.</p>
<p>Get the full access to source code which is “<a href="https://github.com/azadcreative/Responsive-Dropdown-Navigation-Menu" target="_blank">available at Github</a>”.</p>
<h2>Limitations</h2>
<p>The solution provided above is not without limitations. The first and foremost being that the entire design is non-functional without Javascript. Unlike Roger Johansson&#8217;s <a href="http://www.456bereastreet.com/archive/201206/an_alternative_to_select_elements_as_navigation_in_narrow_viewports/">solution</a>, there is no fallback to a simple list in the absence of Javascript.</p>
<p>I have also spotted some irregular behaviour with the dropdowns whilst browsing with the iPhone that could not be traced and debugged. On the iPhone 4, there is a tendency to freeze when there is too many nested lists.</p>
<p>Also, the javascript code presented here uses the &#8216;click&#8217; event which is not optimal for mobile devices. The &#8216;click&#8217; event is significantly slow on MobileSafari (and other mobile browsers) in comparison to mobile-friendly events found in <a href="http://jquerymobile.com/">jQuery Mobile</a>, <a href="http://www.jqmobi.com/">jQMobi</a> and <a href="http://www.jqtouch.com/">jQTouch</a>.</p>
<p>There may be other limitations and pitfalls that I am not aware of. All I can say is that this demonstration is highly experimental and probably not ready for production use.</p>
<h2>Further Reading</h2>
<p>Web design gurus from all over the world have written articles regarding responsive web design that are worthy reads:</p>
<ul>
<li><a title="Responsive Web Design" href="http://www.alistapart.com/articles/responsive-web-design/">Responsive Web Design</a> by Ethan Marcotte at A List Apart.</li>
<li><a href="http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/a-simple-responsive-mobile-first-navigation/">A Simple Responsive Mobile First Navigation</a> from TutsPlus WebDesign.</li>
<li><a title="Fluid Grids" href="http://www.alistapart.com/articles/fluidgrids/">Fluid Grids</a> by Ethan Marcotte.</li>
<li><a title="Responsive Navigation Patterns" href="http://bradfrostweb.com/blog/web/responsive-nav-patterns/">Responsive Navigation Patterns</a> by Brad Frost.</li>
<li><a href="http://www.456bereastreet.com/archive/201206/an_alternative_to_select_elements_as_navigation_in_narrow_viewports/">An alternative to select elements as navigation in narrow viewports</a> by Roger Johansson.</li>
<li>Chris Spooner explains <a href="http://line25.com/tutorials/create-a-responsive-web-design-with-media-queries">How to Create A Responsive Web Design with Media Queries</a>.</li>
<li><a href="http://www.lukew.com/ff/entry.asp?1085">Touch Target Sizes</a> by Luke Wroblewski.</li>
<li><a href="http://www.netmagazine.com/tutorials/build-smart-mobile-navigation-without-hacks">Build a smart mobile navigation without hacks</a> by Aaron Gustafson at .Net Magazine.</li>
</ul>
<h2>Useful Resources</h2>
<p>Some of the resources used in this demonstration in addition to some really interesting web development tools and tips:</p>
<ul>
<li><a title="Tiny Nav" href="http://tinynav.viljamis.com/">TinyNav.js</a> for converting navigations to a select dropdowns for small screens.</li>
<li><a href="http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries">Hardboiled CSS3 Media Queries</a> by Andy Clarke.</li>
<li><a title="Permanent Link to Really Useful Resources and Tools for Responsive Web Design" href="http://www.onextrapixel.com/2012/06/13/really-useful-resources-and-tools-for-responsive-web-design/" rel="bookmark">Really Useful Resources and Tools for Responsive Web Design</a> by Stephanie Walter at onextrapixel.</li>
<li>First-class examples of RWD in practice at <a title="Media Queries" href="http://mediaqueri.es/">MediaQueri.es</a>.</li>
<li><a href="http://filamentgroup.com/lab/overthrow/">Overthrow: An Overflow Polyfill for Responsive Design</a> from Filament Group.</li>
</ul>
<h2>Conclusion</h2>
<p>Learning the Mobile First approach will change your entire mindset towards the web design and the development process. It allows us to focus on the content and prioritise the essential elements over superflous visuals.</p>
<p>Focusing on a responsive navigation is simply the stepping stone towards delivering greater user experiences, in terms of navigability, to users from a vast array of devices.</p>
<p>A disclaimer: At the time of writing, this website is not responsive itself. The responsive version of the site is currently in the over and may take some time to bake. In this article, I have simply shared what I learned whilst developing responsive web designs for clients.</p>
<p>I hope you enjoyed the tutorial and please do share your thoughts in the comment section below.</p>
</div>
</div>
</div>
<ol class="footnotes"><li id="footnote_0_805" class="footnote">It is worth mentioning that the markup of the menu remains exactly the same as “<a title="Bulletproof CSS3 Navigation Menu" href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/" target="_blank">Bulletproof Navigation Menu</a>” tutorial I authored in January 2012.</li><li id="footnote_1_805" class="footnote">Thanks to <a href="http://johanbrook.com">Johan Brook</a></li><li id="footnote_2_805" class="footnote">I am sure there is a better method of checking whether the viewport is small enough for the mobile-nav to be active. I am open to suggestions.</li></ol><p>The post <a href="http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/">Building a Responsive, Mobile-First Navigation Menu</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://azadcreative.com/2012/07/responsive-mobile-first-navigation-menu/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>Bulletproof CSS3 Dropdown Navigation Menu</title>
		<link>http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/</link>
		<comments>http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 10:30:47 +0000</pubDate>
		<dc:creator>Saddam Azad</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Design]]></category>

		<guid isPermaLink="false">http://azadcreative.com/?p=785</guid>
		<description><![CDATA[<p>One of the most critical aspects of web design is the navigation. The navigation, above all else, must be clear, usable and cross-browser compliant. But the tragedy is in the fact that most websites have awful navigation designs that make content difficult to navigate to.

In this tutorial, we are going to build a fabulous cross-browser dropdown navigation menu with the help of some advanced CSS3 properties.</p><p>The post <a href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/">Bulletproof CSS3 Dropdown Navigation Menu</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>One of the most critical aspects of web design is the navigation. The navigation, above all else, must be clear, usable and cross-browser compliant. But the tragedy is in the fact that most websites have awful navigation designs that make content difficult to navigate to.</p>
<p>In this tutorial, we are going to build a fabulous cross-browser dropdown navigation menu with the help of some advanced CSS3 properties. CSS has made leaps and bounds in recent years. With an ever-solidifying specification and widespread browser support, using CSS3 properties today is very much a feasible option.</p>
<p>The world has moved on quite a bit and these days supporting our beloved browser Internet Explorer 6 is no longer a business requirement for most of our clients. Therefore, we can start taking advantage of the new technologies and reap their benefits.</p>
<p>Although CSS3 support still varies from browser to browser as they rely on proprietary vendor-specific properties. We will have a deep look into these properties as this tutorial progresses.</p>
<h2>The demo</h2>
<p>Before we go into the nitty-gritty of front-end web development, let us have a look at what we are trying to accomplish. Without further ado, the fully functional demo is presented below:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/index.html" frameborder="0" style="height:570px;width:700px;">Please upgrade your browser</iframe>
</div>
<p>Such navigation menus are common around the web. But here, in this tutorial, we are going to build it with CSS3 techniques without using a single image. We will also provide a fallback for older non-supporting browsers &#8211; thus achieving maximum cross-browser compatibility.</p>
<h2>The markup</h2>
<p>We are going to start from the basic top-level navigation only. After we have successfully styled the top-level horizontal navigation, we will gradually move to the second and third levels. The top-level navigation is simply an unordered list wrapped around a HTML5 <span class="highlight">&lt;nav&gt;</span> tag.</p>
<pre>&lt;nav&gt;
 &lt;ul&gt;
   &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Breakfast&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Brunch&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Lunch&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Tea&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="#"&gt;Supper&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
&lt;/nav&gt;</pre>
<p>Internet Explorer versions 8 and earlier cannot process HTML5 elements, let alone style them. Therefore, you must include the <a href="http://www.modernizr.com/">Modernizr</a> script in your pages. Modernizr is also handy for the purpose of progressive enhancement.</p>
<h2>The basic CSS scaffolding</h2>
<p>The scaffolding includes <a title="Reset CSS" href="http://meyerweb.com/eric/tools/css/reset/" target="_blank">Eric Meyer&#8217;s CSS Reset</a> and some basic styling that manipulates the markup to make a basic navigation. Let&#8217;s have a closer look:</p>
<p>Firstly, we are going to design a horizontal navigation menu as seen at the top of this website. In the following CSS code, we are going to define the structures of the document and the navigation menu.</p>
<pre>body {
 font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
 font-size: 13px;
 line-height: 30px;
 font-weight: 300;
 background: url(/demo/css3-nav-menu/images/background.jpg);
 min-width: 600px;
}
section.content {
 width: 660px;
 min-width: 500px;
 margin: 0 auto;
 text-align: center;
 zoom: 1;
}
section.content:before,
section.content:after {
 display: table;
 content: "";
 zoom: 1;
}
section.content:after {
 clear: both;
}
header {
 padding: 30px 0 0 0;
 text-align: center;
}</pre>
<p>The CSS code here is pretty much self-explanatory but allow me to explain certain bits and pieces:</p>
<ul>
<li>On the body element, we are applying a background image and setting the typography and layout settings for the entire document.</li>
<li>You are probably wondering what those <span class="highlight">:before</span> and <span class="highlight">:after</span> pseudo-classes are for. Maybe puzzled over the <span class="highlight">display:table</span> and <span class="highlight">content: &#8220;&#8221;</span> too? This is Nicolas Gallagher&#8217;s awesome <a title="A new micro clearfix hack" href="http://nicolasgallagher.com/micro-clearfix-hack/" target="_blank">micro clearfix hack</a>.</li>
</ul>
<pre>nav {
 zoom: 1;
 margin: 20px auto 0 auto;
 width: auto;
 text-align: left;
 background-color: #efefef;
}
nav:before, nav:after {
 display: table;
 content: "";
 zoom: 1;
}
nav:after {
 clear: both;
}</pre>
<pre>nav ul {
 float: left;
 zoom: 1;
 width: auto;
 background: #FFF;
 z-index: 100;
 border-right: 1px solid #e8e8e8;
}
nav ul:before, nav ul:after {
 display: table;
 content: "";
 zoom: 1;
}
nav ul:after {
 clear: both;
}</pre>
<p>The HTML5 nav element and the ul elements both gets a bit of styling and the same clearfix technique as before.</p>
<pre>nav ul li {
 float: left;
 padding: 0 0 10px 0;
 position: relative;
 outline: none;
 line-height: 1.2em;
 padding: 0 1px 0 0;
 border-left: 1px solid #e8e8e8;
}
nav ul a {
 padding: 15px 20px 15px 20px;
 font-weight: bold;
 outline: none;
 float: left;
 display: block;
 zoom: 1;
}
nav ul a:link, nav ul a:visited {
 color: #666;
 text-decoration: none;
 background-color: #ededed;
 background-repeat: repeat-x;
 outline: none;
}
nav ul a:hover, nav ul a:active {
 color: #a67b45;
 text-decoration: none;
 background-color: #ffffff;
}</pre>
<p>Finally, here is what happens:</p>
<ul>
<li>The list items are floated left to make a horizontal navigation menu.</li>
<li>The anchors are also floated left and styled with <span class="highlight">colour</span> and <span class="highlight">background colour</span>.</li>
</ul>
<p>At this point your document should look something like this:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step1.html" frameborder="0" style="height:200px;width:700px;">Please upgrade your browser</iframe>
</div>
<p>Now let&#8217;s get to the good stuff!</p>
<h2>CSS3 Gradient</h2>
<p>Before we go further, be sure to have read Chris Coyier&#8217;s excellent article on <a title="Speed Up with CSS3 Gradients" href="http://css-tricks.com/css3-gradients/">CSS3 Gradients</a> if you have not already.</p>
<p>CSS3 gradients are incredibly useful for designing modern websites. Apart from providing flexibility in implementing design, they also reduce the number of HTTP requests &#8212; thus improving page load times.</p>
<pre>nav {
 ...

 background-repeat: repeat-x;
 background-image: -moz-linear-gradient(top, #ffffff, #ededed); /* FF3.6+ */
 background-image: -ms-linear-gradient(top, #ffffff, #ededed); /* IE10 */
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #ededed)); /* Safari 4+, Chrome 2+ */
 background-image: -webkit-linear-gradient(top, #ffffff, #ededed); /* Safari 5.1+, Chrome 10+ */
 background-image: -o-linear-gradient(top, #ffffff, #ededed); /* Opera 11.10+ */
 background-image: linear-gradient(top, #ffffff, #ededed); /* The standard */
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0); /* IE9 and below */
}</pre>
<p>Firstly, we are adding CSS Gradients on the nav element (the code is highlighted in bold text). It is a subtle white-to-grey gradient applied using background-image property. Browsers that do not support CSS3 Gradients will fall back to the design displayed earlier.</p>
<p>You may have noticed that there are vendor prefixes for different browsers. Here is the order I use:</p>
<ol>
<li>Firstly <span class="highlight">-moz-linear-gradient</span> for older versions of Firefox</li>
<li>Followed by <span class="highlight">-ms-linear-gradient</span> for the upcoming version of Internet Explorer, version 10 (at the time of writing)</li>
<li><span class="highlight">-webkit-gradient</span> for older Webkit based browsers such as Safari 4 and Chrome 2.</li>
<li>For newer versions of Webkit browsers, apply <span class="highlight">-webkit-linear-gradient</span></li>
<li>For Opera versions 11.10 and above, <span class="highlight">-o-linear-gradient</span></li>
<li>The official standard for CSS3 Gradients: <span class="highlight">linear-gradient</span></li>
<li>Finally, everyone&#8217;s favourite browser family (Internet Explorer) needs a proprietary <span class="highlight">filter</span> property, which is not valid CSS.</li>
</ol>
<p>Exhausted? Well, this is the best we can do for now. In the future when everybody has a browser that supports CSS3 Gradients according to the official specification, simply remove all vendor-specific code.<br />
Now let us apply the same gradient to the anchors.</p>
<pre>nav ul a:link, nav ul a:visited {
 ...

 background-image: -moz-linear-gradient(top, #ffffff, #ededed);
 background-image: -ms-linear-gradient(top, #ffffff, #ededed);
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #ededed));
 background-image: -webkit-linear-gradient(top, #ffffff, #ededed);
 background-image: -o-linear-gradient(top, #ffffff, #ededed);
 background-image: linear-gradient(top, #ffffff, #ededed);
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed', GradientType=0);
}
nav ul a:hover, nav ul a:active {
 ...

 background-repeat: repeat-x;
 background-image: -moz-linear-gradient(top, #ededed, #ffffff);
 background-image: -ms-linear-gradient(top, #ededed, #ffffff);
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ededed), color-stop(100%, #ffffff));
 background-image: -webkit-linear-gradient(top, #ededed, #ffffff);
 background-image: -o-linear-gradient(top, #ededed, #ffffff);
 background-image: linear-gradient(top, #ededed, #ffffff);
 filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff', GradientType=0);
}</pre>
<p>The highlighted code above adds a CSS3 gradient on each of the anchors within the navigation menu. For hover and active states, the gradient has been reversed.</p>
<p>Here is what your document should look like now:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step2.html" frameborder="0" style="height:200px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>CSS3 Box Shadows</h2>
<p>Now that the CSS3 Gradients have been applied, things are looking good now. We are going to apply some <a title="CSS3 Box Shadows" href="http://www.css3.info/preview/box-shadow/" target="_blank">CSS3 Box Shadows</a> on the navigation menu to add some visual depth to the design.</p>
<pre>nav {
 ...

 -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
         box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}</pre>
<p>We are going to add some nifty inset CSS Box Shadows on the <span class="highlight">:active</span> pseudo-classes of the anchors. That way when you click on the navigation items, you get a more interactive experience.</p>
<pre>nav ul a:active {
 -webkit-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
    -moz-box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
         box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.3) inset;
}</pre>
<p>As demonstrated below, there are multiple applications of CSS Box Shadows:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step3.html" frameborder="0" style="height:200px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>CSS3 Transition</h2>
<p>CSS3 provides us the ability to include transition effects that were only once available on Adobe Flash<sup><a href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/#footnote_0_785" id="identifier_0_785" class="footnote-link footnote-identifier-link" title="Be sure to read Rich Bradshaw&amp;#8217;s comprehensive guide to CSS3 Transitions, Transforms and Animation.">1</a></sup>. Transitions are meant to be used sensibly to enrich the user experience. In this case, I am attempting to create a desktop-application-esque experience for the users.</p>
<p>The transition is to be placed so that the box shadows and colour of anchors change with a subtle transition effect. It is barely noticeable but adds to the overall smoothness of the interface.</p>
<pre>nav ul a:link, nav ul a:visited {
 ...

 -webkit-transition: all 0.3s ease;
    -moz-transition: all 0.3s ease;
     -ms-transition: all 0.3s ease;
      -o-transition: all 0.3s ease;
         transition: all 0.3s ease;
}

nav ul a:hover, nav ul a:active {
 ...

 -webkit-transition: all 0.1s ease;
    -moz-transition: all 0.1s ease;
     -ms-transition: all 0.1s ease;
      -o-transition: all 0.1s ease;
         transition: all 0.1s ease;
}</pre>
<p>The <span class="highlight">transition</span> is set to <span class="highlight">all</span> because we are transitioning two different properties of the anchor: the link <span class="highlight">colour</span> and <span class="highlight">box-shadow</span>. We could use <span class="highlight">transition: colour</span> and <span class="highlight">transition: box-shadow</span> separately but that would add too much redundancy with all the vendor-specific code.</p>
<p>If you are curious about the syntax of the transition, please refer to Dan Cederholm&#8217;s excellent guide to <a title="Understanding CSS3 Transitions" href="http://www.alistapart.com/articles/understanding-css3-transitions/" target="_blank">CSS3 Transitions</a> on A List Apart.</p>
<p>Let&#8217;s have a closer look at the vendor specific codes:</p>
<ol>
<li>We start with Webkit based browsers</li>
<li>Followed by Mozilla</li>
<li>The upcoming Microsoft Internet Explorer 10 comes with full support for CSS3 Transitions. Versions 9 and below have no support whatsoever.</li>
<li>Opera version 10.5+ supports transitions</li>
<li>Finally, the CSS3 standard.</li>
</ol>
<p>The document should now resemble something like this:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step4.html" frameborder="0" style="height:200px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>The dropdown markup</h2>
<pre>&lt;ul id="menu"&gt;
 &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
 &lt;li class="breakfast active"&gt;&lt;a href="#"&gt;Breakfast&lt;/a&gt;
   &lt;ul&gt;
     &lt;li class="bread"&gt;&lt;a href="#"&gt;Bread&lt;/a&gt;
       &lt;ul&gt;
         &lt;li class="french"&gt;&lt;a href="#"&gt;French&lt;/a&gt;&lt;/li&gt;
         &lt;li class="english"&gt;&lt;a href="#"&gt;White&lt;/a&gt;&lt;/li&gt;
         &lt;li class="brown"&gt;&lt;a href="#"&gt;Brown&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class="eggs"&gt;&lt;a href="#"&gt;Eggs&lt;/a&gt;
       &lt;ul&gt;
         &lt;li&gt;&lt;a href="#"&gt;Eggs Benedict&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Deviled Eggs&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Scotch Eggs&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Scrambled Eggs&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class="bacon"&gt;&lt;a href="#"&gt;Bacon&lt;/a&gt;
       &lt;ul&gt;
         &lt;li&gt;&lt;a href="#"&gt;Canadian&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Southern&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Crisp&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class="jam"&gt;&lt;a href="#"&gt;Preserves&lt;/a&gt;
       &lt;ul&gt;
         &lt;li&gt;&lt;a href="#"&gt;Raspberry&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Gooseberry&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Strawberry&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Blackberry&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class="coffee"&gt;&lt;a href="#"&gt;Coffee&lt;/a&gt;
       &lt;ul&gt;
         &lt;li&gt;&lt;a href="#"&gt;Cappuccino&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Latte&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Espresso&lt;/a&gt;&lt;/li&gt;
         &lt;li&gt;&lt;a href="#"&gt;Macchiato&lt;/a&gt;&lt;/li&gt;
       &lt;/ul&gt;
     &lt;/li&gt;
   &lt;/ul&gt;
 &lt;/li&gt;

...
&lt;/ul&gt;</pre>
<p>The code above is simply a sample of the full markup. As you can see, there are nested unordered lists within the top-level list items. <a href="http://jsfiddle.net/KGK87/6/" target="_blank">Here is the full HTML</a>.</p>
<p>Now that we have a complete nested HTML structure in place, it is time to style them.</p>
<h2>Styling older browsers first</h2>
<p>The principles of <a title="Understanding Progressive Enhancement - ALA" href="http://www.alistapart.com/articles/understandingprogressiveenhancement" target="_blank">progressive enhancement</a> teaches that we must cater for older browsers first before adding more features to newer, more standards-compliant browsers. Following those principles, we will be styling a basic version of the dropdown navigation first.</p>
<pre>#menu li:hover &gt; ul {
 display: block;
}

#menu li:hover &gt; a {
 color: #a67b45;
}

nav li ul {
 display: none;
 margin: 0;
 position: absolute;
 top: 46px;
 left: 0px;
 width: 130px;
 border: none !important;
 padding: 2px;
 background: #999;
 z-index: 1000;
 zoom: 1;
 -webkit-box-shadow: none;
    -moz-box-shadow: none;
         box-shadow: none;
}

nav li ul:before, nav li ul:after {
 display: table;
 content: "";
 zoom: 1;
}

nav li ul:after {
 clear: both;
}

nav li ul a {
 float: none;
}

nav li ul li {
 width: 130px;
 display: block;
 border-top: 1px solid #cfcfcf;
 border-left: none !important;
}

nav li ul li ul {
 display: none;
 left: 130px !important;
 top: -3px;
}</pre>
<p>At the beginning of the code block, you will see that when you hover on the top-level item, its children are displayed by switching its <span class="highlight">display</span> property to <span class="highlight">block</span>.</p>
<p>Then the code goes on to define the structure of the sub-level menu system. Some recurring features such as the clearfix hack and CSS3 Box Shadows are seen at play.</p>
<p>What you will across all browsers at this point is this:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step5.html" frameborder="0" style="height:500px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>Progressively enhanced</h2>
<p>Modernizr adds classes to the html element of the document according to the capabilities available in the browser. We will require browsers that support RGBA to display an enhanced design.</p>
<pre>.rgba nav li &gt; ul {
 padding: 10px;
 left: -10px;
 background: rgba(0, 0, 0, 0.1);
 -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
         border-radius: 10px;
}

.rgba nav li ul li ul {
 top: -10px;
}
 
.rgba nav li &gt; ul {
  margin-top: -1px;
}</pre>
<p>Modernizr adds the class <span class="highlight">rgba</span> to the <span class="highlight">html element</span> of the document when the document loads. Using this method, we can style advanced browsers without affecting the older non-compliant ones.</p>
<p>With the enhanced design, standards-compliant browsers should now display the navigation with all the CSS3 RGBA goodness.</p>
<p>The code above has been update, thanks to a bug kindly reported by <a href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/#comment-2925">Stephen</a>.</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/step6.html" frameborder="0" style="height:500px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>The jQuery plugin</h2>
<p>For the purpose of this navigation, we are going to build a custom jQuery plugin. The purpose of the plugin is to:</p>
<ol>
<li>Find out if the navigation items have any children. If they do, add a <span class="highlight">hasChildren</span> classname</li>
<li>Wrap the inside list items anchors with a <span class="highlight">span</span>, which is useful for applying styling</li>
<li>Apply the class <span class="highlight">hover</span> when an onHover event occurs on the list items</li>
</ol>
<p>Allow me to give to give you the code straight away:</p>
<pre>$.fn.nav_dropdown = function(options) {

 var defaults = {};
 var opts = $.extend(defaults, options);

 // Apply on those items with children
 this.each(function() {
   $(this).find('li').each(function() {
     if($(this).find("ul").length &gt; 0) {
       $(this).addClass("hasChildren");
       $(this).find('&gt; a').wrapInner("&lt;span&gt;&lt;/span&gt;");
     }
   });
 });

 // Apply on all list items
 $(this).find("li").hover(function() {
   $(this).addClass('hover');
 }, function() {
   $(this).removeClass('hover');
 });

 $('li').has('ul').hover(function(){
   $(this).children('ul').show();
 }, function() {
   $(this).children('ul').hide();
 });
};</pre>
<p>As you can see above, the jQuery plugin is very basic and nothing to be overwhelmed with. I am using the wonderful <a title="A Plugin Development Pattern" href="http://www.learningjquery.com/2007/10/a-plugin-development-pattern" target="_blank">jQuery plugin authoring boilerplate</a> provided by Mike Alsup of Learning jQuery.</p>
<p>Now all you have to do is to call the function and tell it what HTML element to apply it to:</p>
<pre>$(function() {
  $('nav').nav_dropdown();
});</pre>
<p>We have added the <span class="highlight">hasChildren</span> class to the list items that contain further items as children. We will have to provide additional styling, so that users can visually tell them apart from the childless items.</p>
<h2>Styling items with children</h2>
<p>Before we go into the CSS styling, we have to create a CSS Sprite with arrows that act as pointers. There are four elements within the sprite as demonstrated below.</p>
<p><img class="alignnone size-full wp-image-799" title="The CSS Image Sprite" src="http://i0.wp.com/azadcreative.com/wp-content/uploads/2012/01/Sprite-def.jpg?resize=700%2C200" alt="The CSS Image Sprite" data-recalc-dims="1" /></p>
<p>Now that we have an image with arrows, let us apply the styling. Firstly, the top-level items get their visual cues with the following code:</p>
<pre>nav ul li.hasChildren a span {
 padding: 0 20px 0 0;
 background: url(/demo/css3-nav-menu/images/sprite.png);
 background-position: right top;
 background-repeat: no-repeat;
 display: block;
}
nav ul li.hasChildren a:hover span, nav ul li.hasChildren.hover a span {
 background-position: right -50px;
}</pre>
<p>Now for the sub-level navigation items, we are going to apply some styling:</p>
<pre>nav li ul li.hasChildren a &gt; span {
 background: url(/demo/css3-nav-menu/images/sprite.png);
 background-position: right -97px !important;
 background-repeat: no-repeat;
}
nav li ul li.hasChildren a:hover &gt; span,
nav li ul li.hasChildren.hover &gt; a span {
 background-position: right -138px !important;
}</pre>
<p>With the help of a little javascript and an image sprite, we have created a navigation where items are differentiable according to whether they have children.</p>
<p>And viola! That is all there is. Here is the final demo, one more time:</p>
<div class="iframe-wrapper">
  <iframe src="/demo/css3-nav-menu/index.html" frameborder="0" style="height:570px;width:700px;">Please upgrade your browser</iframe>
</div>
<h2>Conclusion</h2>
<p>And we&#8217;re done! The final code is <a title="Bulletproof CSS3 Dropdown Navigation Menu" href="http://jsfiddle.net/KGK87/6/" target="_blank">available at JSFiddle</a> for your convenience.</p>
<p>Congratulations, you now have a completely cross-browser compliant CSS3 Navigation Menu that is fully functional in older non-supporting browsers and takes advantage of advanced CSS3 features in modern browsers.</p>
<p>If this tutorial has been helpful to you or If you happen to be a front-end development guru who knows more than me, your feedback would be very much appreciated.</p>
<h3>Further reading</h3>
<p>For further reading, here are some excellent resources from world-class web developers:</p>
<ul>
<li><a title="Introduction to CSS3 – Borders" href="http://designshack.net/articles/introduction-to-css3-part-2-borders">Introduction to CSS3 &#8211; Borders</a> at DesignShack.</li>
<li><a title="The elusive CSS Border Gradient" href="http://blog.nateps.com/the-elusive-css-border-gradient">The elusive CSS Border Gradient</a> by Nate Smith.</li>
<li>Web Designer Wall has the beginner&#8217;s guide to <a title="Cross-Browser CSS Gradient" href="http://webdesignerwall.com/tutorials/cross-browser-css-gradient">Cross-browser CSS3 Gradient</a>.</li>
</ul>
<p>Please use this code for learning purposes only and please do not blindly copy/paste your way to glory. I cannot guarantee that the code will not break your existing layout. I herewith declare myself not responsible if the code presented here happens to break layouts or kill your neighbour&#8217;s cat.</p>
<h3>What can you do with an unordered list?</h3>
<p>As demonstrated above, we have styled a simple unordered list to design an outstanding cross-browser compliant navigation menu. What can you do with a humble <span class="highlight">ul</span>?</p>
<p>Start <a href="http://jsfiddle.net/KGK87/6/" target="_blank">forking the code</a> and show us what you can do. Make sure you link to the live demo in your comment below.</p>
<ol class="footnotes"><li id="footnote_0_785" class="footnote">Be sure to read Rich Bradshaw&#8217;s comprehensive guide to <a title="Using CSS3 Transitions, Transforms and Animation" href="http://css3.bradshawenterprises.com/all/">CSS3 Transitions, Transforms and Animation</a>.</li></ol><p>The post <a href="http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/">Bulletproof CSS3 Dropdown Navigation Menu</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://azadcreative.com/2012/01/bulletproof-css3-dropdown-navigation-menu/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Proofing Tools for Web Designers and Agencies</title>
		<link>http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/</link>
		<comments>http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 10:00:46 +0000</pubDate>
		<dc:creator>Saddam Azad</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Freelancing]]></category>

		<guid isPermaLink="false">http://azadcreative.com/?p=553</guid>
		<description><![CDATA[<p><p>Clients are often short on words to truly explain their expectations and reactions in detail, over traditional forms of communication. As a designer, you may have found yourself struggling to understand exactly what the client wants from your designs once you&#8217;ve submitted a few mockups. Usually they want something to &#8220;pop&#8221;.</p>
<p>Thankfully, web technologies have advanced to [...]</p></p><p>The post <a href="http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/">Proofing Tools for Web Designers and Agencies</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Clients are often short on words to truly explain their expectations and reactions in detail, over traditional forms of communication. As a designer, you may have found yourself struggling to understand exactly what the client wants from your designs once you&#8217;ve submitted a few mockups. Usually they want something to &#8220;pop&#8221;.</p>
<p>Thankfully, web technologies have advanced to the point that newer, more efficient means of communications have arrived &#8211; that are specifically tailored for this purpose.</p>
<p>I like to gather feedback, early and often. For this, I use web based proofing services. They are cheap and very efficient is maintaining an efficient channel of communication with the client. They help keep the designer and the client stay on the same page at all time.</p>
<p>Over the last 12 months, quite a few contenders have emerged in this space. Let&#8217;s have a look:</p>
<h2>ProofHQ</h2>
<p><a href="http://proofhq.com"><img class="alignright  wp-image-729" title="ProofHQ" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2011/12/ProofHQ.jpg" alt="ProofHQ" data-recalc-dims="1" /></a>ProofHQ is a comprehensive proofing tool &#8212; complete with contact and client management and full featured annotation, review and approval process management.</p>
<p>The app provides a very intuitive interface for feedback and approval management for designers as well as decision makers in the client company.</p>
<p>ProofHQ is not just limited to web designers, it can also satisfy the proofing needs of professional print designers. It handles Adobe Creative Suite<sup><a href="http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/#footnote_0_553" id="identifier_0_553" class="footnote-link footnote-identifier-link" title="Photoshop .PSD and Illustrator .AI files have been tested. Other formats may or may not be supported.">1</a></sup> and multi-page PDF files with ease.</p>
<p>Among many great features, one that stands out is Basecamp integration. The seamless integration with the existing projects and milestones in Basecamp makes ProofHQ a perfect companion app.</p>
<p>Drag-and-Drop integration with the desktop and version management of concepts are nifty features that make this app truly fantastic.</p>
<div id="attachment_728" class="wp-caption alignnone" style="width: 670px"><img class=" wp-image-728 " title="ProofHQ Annotate" src="http://i0.wp.com/azadcreative.com/wp-content/uploads/2011/12/ProofHQ-Annotate.jpg?resize=660%2C557" alt="ProofHQ Annotation and Comment Interface" data-recalc-dims="1" /><p class="wp-caption-text">ProofHQ Annotation and Comment Interface</p></div>
<p>For the solitary freelance designer, there is the $17/month package with 2GB is storage and up to 30 proofs per month. There are 5 more packages, suitable for teams of all sizes, from 2 to 40 users.</p>
<p>Up to 40 GB of storage and 1000 proofs per month is enough for quite a large company. The price tag of $299/month is more than reasonable.</p>
<h2>Onotate</h2>
<p><a href="http://onotate.com"><img class="alignright  wp-image-731" title="Onotate" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2011/12/onotate.png" alt="Onotate" data-recalc-dims="1" /></a>Onotate is another great service that focuses on annotation of design mockups. This tool gives the reviewer some really nifty tools to pinpoint the issues and annotate them clearly for the designer.</p>
<p>The simplicity on Onotate is sheer brilliance. The creation of Projects and Stages, as well the upload of concepts was a seamless process &#8212; all done through a brilliantly minimalistic interface.</p>
<p>The reviewers are given straight-forward tools for annotation and commenting on the concept. You can choose your mood when leaving a feedback on a concept.</p>
<div id="attachment_732" class="wp-caption alignnone" style="width: 670px"><img class=" wp-image-732 " title="Onotate Annotation" src="http://i2.wp.com/azadcreative.com/wp-content/uploads/2011/12/Onotate-annotation.jpg?resize=660%2C287" alt="Onotate Annotation" data-recalc-dims="1" /><p class="wp-caption-text">Onotate Annotation Interface</p></div>
<p>Onotate would be perfect for the freelance designer showing off their concepts and prototypes to clients and gathering feedback. I would imagine the client would love the minimalistic interface that lets them get the work done without getting in the way.</p>
<p>The pricing plan is very simple. The <strong>only</strong> plan is $15/month and provides access for unlimited people to unlimited storage. Very good value for money, if you ask me.</p>
<h2>DesignSignoff</h2>
<p><a href="http://designsignoff.com/"><img class="alignright  wp-image-737" title="DesignSignOff" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2011/12/DesignSignOff.gif" alt="DesignSignOff" data-recalc-dims="1" /></a>This is a startup which recently acquired GetSignOff and have cooked up something quite fabulous.</p>
<p>DesignSignOff, as the name suggests, focuses on the process of review and sign-off of web design design prototypes. The app allows smooth collaboration between all parties and helps agencies get to the all-important milestone &#8211; Design SignOff.</p>
<p>What differentiates this app from the rest is its outstanding presentation toolkit. The app is designed for agencies that pitch concepts to clients. The clients can view the concepts in their own browsers and when the time is right, leave valuable feedback.</p>
<p>DesignSignOff is not just for design review and approval, it handles everything from pitch to sign-off. This is a truly innovative solution that alleviates much headache and streamlines the process at many top agencies.</p>
<div id="attachment_736" class="wp-caption alignnone" style="width: 670px"><img class=" wp-image-736 " title="DesignSignOff Review" src="http://i0.wp.com/azadcreative.com/wp-content/uploads/2011/12/DesignSignOff-Review.jpg?resize=660%2C452" alt="DesignSignOff Review" data-recalc-dims="1" /><p class="wp-caption-text">DesignSignOff Review Interface</p></div>
<p>The package for &#8216;the little guy&#8217; is $12 per month provides access to 1 user and allows 3 clients and up to 10 projects.</p>
<p>For small groups, the $25 per month package allows 20 clients and 50 projects, as well as SSL security. If you&#8217;re a behemoth looking for everything unlimited, it will set you back by a rather measly $35 a month.</p>
<h2>ConceptShare</h2>
<p><img class="alignright" title="ConceptShare" src="http://i2.wp.com/azadcreative.com/wp-content/uploads/2011/12/ConceptShare.png" alt="ConceptShare" data-recalc-dims="1" />ConceptShare is the leading tool for design presentation and review. It cannot be easier to upload your design proofs for review. Almost every client I have worked with have familiarized with the interface of ConceptShare within minutes.</p>
<p><strong>Update:</strong> There has been a few changes with ConceptShare. They are now focused towards agencies and businesses looking for proofing software. If you are representing an agency, get in touch with their Sales Department for a trial.</p>
<h2>Conclusion</h2>
<p>In my experience, the clients love web based proofing because it allows them to show off the designer&#8217;s work to their colleagues and loved ones and gather their opinions which, in turn, shapes their own opinion. Nearly half my clients come back to me with feedback from their wives!</p>
<p>Web based Design Proofing/Review and Sign-off applications are a major part of my design process.</p>
<p>What are your experiences with such applications? Let me know your thoughts and opinion.</p>
<ol class="footnotes"><li id="footnote_0_553" class="footnote">Photoshop .PSD and Illustrator .AI files have been tested. Other formats may or may not be supported.</li></ol><p>The post <a href="http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/">Proofing Tools for Web Designers and Agencies</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://azadcreative.com/2011/12/proofing-tools-for-web-designers-and-agencies/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>5 Tips for Creating a Fabulous Web Design Portfolio</title>
		<link>http://azadcreative.com/2011/12/five-tips-for-creating-a-fabulous-web-design-portfolio/</link>
		<comments>http://azadcreative.com/2011/12/five-tips-for-creating-a-fabulous-web-design-portfolio/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 12:00:06 +0000</pubDate>
		<dc:creator>Saddam Azad</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Freelancing]]></category>

		<guid isPermaLink="false">http://azadcreative.com/?p=706</guid>
		<description><![CDATA[<p><p>Your design portfolio is your virtual shop-window the whole world can see. Your portfolio not only conveys what you have done, it shows what you can do for a prospective client.</p>
<p>A client is likely to scan your portfolio before deciding to contact you. It is very likely that the reviewer is evaluating other portfolios as [...]</p></p><p>The post <a href="http://azadcreative.com/2011/12/five-tips-for-creating-a-fabulous-web-design-portfolio/">5 Tips for Creating a Fabulous Web Design Portfolio</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Your design portfolio is your virtual shop-window the whole world can see. Your portfolio not only conveys what you have done, it shows what you can do for a prospective client.</p>
<p>A client is likely to scan your portfolio before deciding to contact you. It is very likely that the reviewer is evaluating other portfolios as well. So how do you ensure that yours stand out amongst the crowd?</p>
<p>In this highly competitive industry, it is not enough to have some excellent pieces of work under your belt &#8212; you must also display your work and show a lot of professionalism in doing so.</p>
<p>In my 8 years in the industry, I have picked up a few tricks about how to design a portfolio with a punch and a kick.<span id="more-706"></span></p>
<div id="attachment_723" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-723" title="design-portfolio" src="http://i1.wp.com/azadcreative.com/wp-content/uploads/2011/12/design-portfolio.jpg?resize=660%2C367" alt="5 Tips for Creating a Fabulous Web Design Portfolio" data-recalc-dims="1" /><p class="wp-caption-text">Photo: {link:http://www.flickr.com/photos/22897666@N00/5489630899/}Catskills Photography{/link}</p></div>
<h2>Tell a story</h2>
<p>Most designers display a thumbnail of their portfolio piece and add a link to the live website. That, alone, is not enough to tell a reviewer what they want to know.</p>
<p>Tell the world about the experiences you&#8217;ve had whilst working on the project. Write a few sentences about the project, the people behind it and how it served the ultimate business objective of the client.</p>
<p>Focus on the deliverables that were expected from you at the beginning of the project. Let the world know how your work contributed to the success of the project and how it benefits the client&#8217;s bottom-line.</p>
<p>If you wish to, write about the hiccups along the way and how it helped you grow as a professional.</p>
<p>Your portfolio is not just a bunch of cropped images, it is a collection of experiences &#8211; and there&#8217;s a story behind every experience. Tell the story.</p>
<h2>Create actionable steps for visitors</h2>
<p>Once the reviewers have looked around, they would want to contact you via email, twitter or any other media. Make sure the contact options are easily available to all viewers. A simple actionable step to your inbox goes a long way.</p>
<p>Use strong call-to-actions to invite viewers to find out more about you and your services. Ask them to write to you and leave a comment. Ask for a job or a referral.</p>
<p>The people who are viewing your portfolio are likely people who are looking for a designer in their team. Show them what value you add to the company and why you should be hired.</p>
<h2>Only display your best work</h2>
<p>We have all designed something that we&#8217;re not particularly proud of. There were times when the client&#8217;s demands became the direction for the design, instead of your own liking, resulting in rather mediocre results.</p>
<p>There were times when the client employed other people to modify (read bastardize) my work. The masterpiece that I thought I created is no longer what it was.</p>
<p>It is easy to get carried away and showcase every little piece you have ever created. But think of what a prospective client might think of you when they see a mediocre or mutilated piece of work in your portfolio.</p>
<p>Not every piece is portfolio-worthy. Learn to let go.</p>
<h2>Tag every piece with meta information</h2>
<p>With each piece of work in your portfolio, display some key information such as:</p>
<ul>
<li>The name of the client.</li>
<li>How long you have worked for the client.</li>
<li>Your specific role in the project.</li>
<li>What deliverables you produced.</li>
</ul>
<p>Some designers even showcase what software they have used in the process. Customer testimonials are optional but they create a great bit of credibility for yourself in the eyes of the reviewers. Focus on the tangible benefits your client enjoyed as a direct benefit from your work, if you happen to have such information.</p>
<h2>Show some personality</h2>
<p>Your portfolio is an image your personality and your primary marketable skill. If your skill is User Interface Design, specifically for Web Apps, make your portfolio as clean, intuitive and usable as possible.</p>
<p>If you&#8217;re a Graphic Designer by heart, make sure your portfolio website speaks that language.</p>
<h2>Bonus tip: A little Marketing knowledge goes a long way</h2>
<p>The reviewers visiting your online portfolio are likely to be individuals whose sole focus is to deliver greater value to their end consumers. They will consider you, as a designer, only when they know that you care capable of adding more value to their products or services &#8211; which will, in turn, benefit their consumers.</p>
<p>Every piece in your portfolio needs to reflect how your services benefitted your client organisations. A little knowledge of marketing will help you gain insight as to how clients perceive their own companies and new hires.</p>
<p>For employers, even a new hire is an investment. When they hire a web designer, they will be making a significant investment in wages and overhead. As any businessperson would tell you, every investment is made to make a profit &#8212; a Return on Investment (ROI).</p>
<p>Your portfolio is not just for your own bragging rights, it is meant to influence prospective employers who need convincing. You need to convince them, through your portfolio, that you are capable of producing value and delivering a significant ROI for their businesses.</p>
<p>The post <a href="http://azadcreative.com/2011/12/five-tips-for-creating-a-fabulous-web-design-portfolio/">5 Tips for Creating a Fabulous Web Design Portfolio</a> appeared first on <a href="http://azadcreative.com">Saddam Azad - User Interface Designer &amp; Front-end Engineer.</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://azadcreative.com/2011/12/five-tips-for-creating-a-fabulous-web-design-portfolio/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
