Building a Responsive Layout With Skeleton: Navigation
videos

Building a Responsive Layout With Skeleton: Navigation

Tutorial Details
  • Topic: Responsive Web Design
  • Difficulty: Intermediate
  • Screencast duration: 48 mins
This entry is part 3 of 8 in the series Building a Responsive Layout With Skeleton

Our Skeleton layout contains a number of responsive challenges, not least of which being the primary navigation. In these screencasts we’ll prepare things by tidying up the baseline grid, talking about image replacement, styling the menu and finally using some jQuery to help make things responsive.


Baseline Grid and Logo

Before we dive into the primary navigation itself, we need to tidy up a few aspects of our layout. To begin with we’ll need to make sure that all measurements we have so far work in harmony with our baseline grid. Secondly, we’re going to talk about an alternative approach to image replacement which highlights some important points about performance.

Alternatively, Download the video, or subscribe to Webdesigntuts+ screencasts via iTunes or YouTube!


Primary Navigation Base

The basis of our primary navigation is a slick looking menu with a dropdown submenu and some subtle transitions. In this video we’re going to cover the basic mechanics of a css dropdown menu, plus some points (relating to what we were talking about with image replacement) about performance and accessibility.

Alternatively, Download the video, or subscribe to Webdesigntuts+ screencasts via iTunes or YouTube!


Responsive Navigation

Having gotten the navigation working, it’s time to consider how our mobile users will experience it. We’re going to use jQuery and CSS media queries to swap out the standard menu with a <select> alternative for small screen sizes.

Alternatively, Download the video, or subscribe to Webdesigntuts+ screencasts via iTunes or YouTube


One Last Point

As mentioned by Michael, the submenu items as they currently stand will look dreadful when they drop drown from small menu items:

This is because the submenu width is set to equal the width of the parent link. Text within the links is wrapping and the whole thing is messed up. We can solve this by adding one additional rule to the submenu links:

nav.primary ul ul li a {
white-space: nowrap;
}

which prevents text wrapping and forces the submenu to grow width-ways. Much better!


Additional Resources

Some useful links to further build on what’s been covered in these videos.

Series Navigation<< Building a Responsive Layout With Skeleton: Starting OutBuilding a Responsive Layout With Skeleton: jQuery Plugins >>

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://uranbold.com Uranbold

    Big like! I was Just looking for this…

  • Allar

    Great, I was waiting for that

  • http://georgedina.ro/ George Dina

    Nice!
    I was just using Skeleton for one of the projects I am working right now :)

  • http://www.chrisschnedl.com/ Chris Schnedl

    Great Tutorial!
    Yes, Skeleton is really great. I also have made some projects with it.

  • Pingback: Responsive based layouts | Pearltrees

  • supprof

    thank you very mutch
    very good tutorial

  • dj

    Well done mate! Well organized, well focused and well delivered – reminiscent of how Remy Sharp used to do his tuts. From your examples I’m much more an advocate for baseline styling now because I can see how easily it is achieved even though often-times minimally noticeable on the page. I just wish i could understand why the “max size” 960 seems to be the fallback for most developers. My screen has long been wider than that. I can understand the apparent compromise back in the day as a middle ground for desktops v. laptops v. mobile.

    Now, even though we’ve got @media queries and responsive design coming out of the woodwork – I’m still looking at nearly 50% completely wasted space on my screen! To me, this design is readable; but almost asks for some breathing room width-wise. It could easily be expanded aesthetically – and, so far, is about the only glaring deficit I can see with using the grid you mentioned.

    You gave us a great example of modifying a baseline grid – how about doing the same for the structural grid and expand it out to better utilize the size of the majority of desktop users? Also, I sure hope you are giving some thought about continuing this series into the “WordPress” phase – even if you needed to jump to WPtuts to finish it.

    • http://www.snaptin.com Ian Yates
      Author

      Thanks dj, and point (once again) well made :) It won’t be much trouble to extend the Skeleton boilerplate media queries so that larger screen resolutions are catered for – I’ll see about tacking that onto the end of the series.

      Aside from the technicalities, it should present some interesting design decisions..

  • Ryan

    You’re a fantastic teacher. I am really enjoying these tutorials and love the detail you go into.

  • http://enora.josse.free.fr Enora

    The dropdown menu is quite messed up in IE7. It appears on top of the ‘Entertainment’ item and the links in it aren’t fully clickable (the light grey background doesn’t extend fully to the ul’s right side and the two last items simply can’t be hovered).

    Could make it work by setting the ‘nav.primary ul li a’ to display:block instead of inline-block, and using width:100% instead of min-width for the ‘nav.primary ul ul’ . Also I added a height of 35px to the a’s inside the second ul.

    Don’t know if these changes are right, could anyone explain me why the inline-block and min-width properties were necessary in the first place ? Any insight would be appreciated :)

    Anyway thanks for this nice series !

    • http://www.snaptin.com Ian Yates
      Author

      Hmm – sorry about that. I hadn’t checked things out in IE7. Your alterations may well do the job, but the problem really lies in the positioning. I’d stated that the position was absolute, which was enough for modern browsers to assume correctly what was going on, but IE7 needs clearer instructions. Try adding:

      	top:100%;
      	left: 0;
      

      to the nested ul nav.primary ul ul. It will position the sub menu correctly against its parent li.

      As for the min-width: 100%, that just makes sure that the submenu is at least as wide as its parent link. Not crucial, more a personal aesthetic preference.

      inline-block is a useful display technique which allows you to treat an element as though it’s inline (ie: it won’t fill up 100% of available width space) whilst also allowing you to specify its dimensions etc. (not possible with an inline element).

      I hope that’s helped!

      • http://enora.josse.free.fr Enora

        Indeed it’s now positionned the way it should be with your addition. But still it seems min-width doesn’t work in IE7. Anyway no big deal, thanks for your explanations !

  • Matheus

    Why did you stop the FW tuts :( Miss those!

    • http://www.snaptin.com Ian Yates
      Author

      It certainly wasn’t a conscious decision Matheus, sorry! You’re right, it’s a while since a quality FW designer has crossed my path – I’ll get right on it :)

  • http://suvanno.com.np web design nepal

    awesome tutorials, i have been searching for such a great navigation style.

  • Vlad

    Really great stuff, just can’t wait for the next lesson.

  • http://route19designs.com Dan Excel

    The demo does not work at all in IE9. I am not a fan of IE, but do you really think it should be ignored due to its market share?

    • http://www.snaptin.com Ian Yates
      Author

      Not entirely true (I’d neglected to upload the correct version with the IE background fallback) and, no, obviously I don’t think it should be ignored – a fairly extreme conclusion to draw.

      There is still a bug in the dropdown menu (something wrong with the submenu hover states), and the flickr images aren’t looking too hot, so I’ll have to look further into that. Plenty to talk about in tutorials further down the line..

  • Serge

    Great series, keep up the good work.
    I can see many of the tricks can be applied to bootstrap.

    I wonder if something like this can be built into sharepoint masterpages.
    Will keep on following!

    Thanks!

  • http://www.onlinetraffic.co.nz Lloyd

    This is great, am keeping watch on this

  • janice

    This is a very well taught series, look forward to the rest of it. Thanks.

  • Laure

    Very nice tuto !!

    But I’d a problem. The link on “select” doesn’t work.
    I’ve made an alert on “change” function… it doesn’t work anymore !

    An idea for the origine of the problem ??

    Sorry for my english, I’am french ! ;-)

    • http://www.snaptin.com Ian Yates
      Author

      Hi Laure – difficult for me to say without seeing exactly what you’ve done.. Any chance you can post your snippets?

  • Laure

    Hi Ian,

    Thanks for your response.

    Extract of my code :

    //Menu pour mobile et tablette
    $(document).ready(function() {
    $(“”).appendTo(“#conteneur header nav”);

    //Default option “Voir les rubriques…”
    $(“”, {
    “selected”:”selected”,
    “value”:”",
    “text”:”Voir les rubriques…”
    }).appendTo(“nav select”);

    //Menu items
    $(“#conteneur header nav li a”).each(function(){
    var el = $(this);
    $(“”, {
    “value”:el.attr(“href”),
    “text”:el.text()
    }).appendTo(“nav select”);});
    });

    //Link
    $(“nav select”).change(function() {
    window.location = $(this).find(“option:selected”).val();
    });

    Hope you can help me with that ! ;-)

    • http://www.snaptin.com Ian Yates
      Author

      Difficult to see exactly where the problem lies here – I’m afraid posting in the comments has parsed some of the code and messed things up.. :(

      Perhaps your ready method is just missing the closing curly braces (});)?

      Anyhow, I’ve put together the snippets according to what I think your markup is (this is based on your nav element appearing within #conteneur header). Try it – I hope it helps!

      //Menu pour mobile et tablette
      $(document).ready(function() {
      	//build dropdown
      	$("<select />").appendTo("#conteneur header nav");
      	//Default option "Voir les rubriques…"
      	$("<option />", {
      	   "selected": "selected",
      	   "value"   : "",
      	   "text"    : "Voir les rubriques…"
      	}).appendTo("nav select");
      	//Menu items
      	$("#conteneur header nav li a").each(function() {
      	 	var el = $(this);
      	 	$("<option />", {
      	     	"value"   : el.attr("href"),
      	    	"text"    : el.text()
      	 	}).appendTo("nav select");
      	});
      	//Link
        	$("nav select").change(function() {
          	window.location = $(this).find("option:selected").val();
        	});
      });
      

      PS) If you ever want your code to appear on Tuts+ in the highlighter like this, stick it between shortcode tags: [html] [/html] – or throw it into a Fiddle for all to see!

      • Laure

        Hi Ian,

        Thank you very much for your help!
        So it was actually a stupid oversight on my part!

        And thank you for the info on how to post the code! I should remember.

        Again thank you for this great tutorial! Understandable even for a frenchie!

  • http://tutorialabout.com Tu Nguyen

    This is great. I’m thinking about developing some nice responsive layout for my next project using skeleton now. I like the tutorial and the theme also.

  • Pingback: Building a Responsive Layout With Skeleton: Navigation | Webdesigntuts+ » Web Design

  • http://NewMediaDrive.com Mila Jones

    Thank-you for this! Very well done!

  • Michael Harris

    Thank you so much for this tutorial Ian. It’s been 10yrs since I’ve had to properly create a website from scratch, and I’m impressed by the quality of this tutorial series.

    I’ve happily learned this evening how to use a mobile-ready boilerplate to get my site layout exactly how I want it, do menus using CSS only (I hate using jScript methods), and of course that use of jQuery to generate a mobile-friendly menu is inspired.

    And as for what it’s achieved, I pretty much have my site template finished in the space of a Saturday evening – and I can get straight on to prepping content (I cheated and worked on the information architecture between videos) to launch it next week.

    Again, thanks so much for your work – it’s really appreciated.

  • Anderson Lucas

    Amazing Tuts! :P
    Thanks a lot…

  • http://rodleg.wordpress.com/tutoriels/ Rod-Leg

    very nice tuto ! thank you

  • http://coder-design.com/ coder-design

    I had been looking for create a responsive navigation. It is a good tutorial. Thanks for sharing.

  • Cy

    With the jQuery part where the drop down menu fades in.

    Does anyone else run into issues with IE. or the fade not happening and the drop down isn’t visible?

    Thanks

    • http://www.snaptin.com Ian Yates
      Author

      Hi Cy, there’s no jQuery involved in the dropdown menu – it’s pure CSS. There is an issue in IE7 (I think) with the first anchor in the submenu staying highlighted, even when you’ve moved the cursor beyond it, but that’s the only problem I’m aware of at the moment. As far as I know, IE8 and IE9 don’t experience any issues.

      I’ll be looking at cross-browser checking in the next video, but if you spot any other bugs please let me know!

  • Karam S

    Hi Ian.

    This tutorial is great! But for some reason my version wont let the drop down disappear. It is constantly on show rather than being replaced by the actual navigation menu. I’m pretty sure its a silly mistake by me (i’m new at this).

    Here’s the code, please tell me if you need any additional code because i am not sure which sections you will need:

    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script&gt;
    	<script src="javascripts/tabs.js"></script>
        <!--chris coyier's little dropdown select-->
        <script type="text/javascript">
    		$(document).ready(function() {
    			//build dropdown
    			$("<select />").appendTo(".navigation nav div");
    				// Create default option "Go to..."
    				$("<option />", {
    				   "selected": "selected",
    				   "value"   : "",
    				   "text"    : "Go to..."
    				}).appendTo("nav select");
    			// Populate dropdown with menu items
    				$(".navigation nav li a").each(function() {
    				 var el = $(this);
    				 $("<option />", {
    					 "value"   : el.attr("href"),
    					 "text"    : el.text()
    				 }).appendTo("nav select");
    				});
    				//make responsive dropdown menu actually work
    				$("nav select").change(function() {
      					window.location = $(this).find("option:selected").val();
    				});
    			});
    	</script>
    
    <div class="band navigation">
                <nav class="container primary">
                    <div class="sixteen columns">
                        <ul>
                        <li><a href="#">Home</a></li>
                        <li><a href="#">History</a></li>
                        <li><a href="#">Downloads</a></a>
                        	<ul>
                            <li><a href="#">-Music</a></li>
                            <li><a href="#">-Video</a></li>
                            </ul>
                        </li>
                        <li><a href="#">Contact</a></li>
                        </ul>
                    </div>
                </nav><!--end container-->
            </div><!--end band-->
    

    Thanks, Karam

    • http://www.snaptin.com Ian Yates
      Author

      Hi Karam, what you’ve done with markup and jQuery so far looks fine, as you’ll be able to tell by the presence of a select menu alongside your original navigation.

      The visibility of each navigation type is controlled with CSS; by default you should have stated in your CSS that the select isn’t displayed (shown here with a couple of additional styles):

      nav.primary select {
      	display: none;
      	width:  100%;
      	height: 28px;
      	margin: 21px 0;
      }
      

      You then rely on media queries to bring it back into the picture and hide the original navigation, when certain screen size criteria are met:

      	/* All Mobile Sizes (devices and browser) */
      	@media only screen and (max-width: 767px) {
      		nav.primary select {
      			display: block;
      		}
      		nav.primary ul {
      			display: none;
      		}
      	}
      

      Here you can see that we’re dealing with a media query for any screen width up to 767px; effectively all smaller mobile devices (built on the fact that tablets such as iPads have a minimum viewport width of 768px). We’ve brought our select back into the picture with display: block and we’ve hidden the other navigation with display: none.

      Hope that clears things up!

      • Karam S

        Hi Ian,

        Thanks for getting back to me so quickly. I looked at your code and realised that i made the smallest mistake in the CSS Media Queries.

        /* All Mobile Sizes (devices and browser) */
        @media only screen and (max-width: 767px) {}
        

        I forgot to open the curly brackets at the end :$

        Once again thanks for replying, the tutorials are great :)

  • http://gregdixson.com Greg

    I know I won’t be anything until I’m whistling a tune while coding Javascript!

    This is a great series and good to see something so detailed and complete. Many thanks Ian!

    btw I do have a nav issue/bug of the nav items not being of equal height, so the hover doesn’t cover completely the nav items (leaves a maybe 8px gap at the top). Not sure what that could be??.. I’ll have to check through my code. Apart from that all good!

    • http://www.snaptin.com Ian Yates
      Author

      Note to self – try not to whistle when recording :)

      Not sure what your nav issue could be, unless you’ve added a larger line-height to the li surrounding your anchors? Or margin to the anchors? Did you remember to zero the margins on the nav list and list items? The anchors should force the list items out to their dimensions..

      Anyway, I’m sure you’ll figure it out, otherwise feel free to throw the results online somewhere and I’ll take a look. Cheers :)

  • Michael

    I am enjoying the tutorial yet one thing puzzles me: in hiding the text of the logo (h1) the idea is presented to give the font dimensions of 0 pixels but I believe that for search engines this presents an issue. Google for instance, may remove your site from their index when you have text hidden like this.

    Check this out: http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66353

    Perhaps there is an exception to this policy that I am not aware of, …looking forward to your thoughts on this.

    Greetings Michael

    • http://www.snaptin.com Ian Yates
      Author

      Hi Michael, that’s a fair point, but Google these days is pretty good in distinguishing between image replacement (where text is replaced with a representative image/logo etc. as in our case) and straight-forward burying of text.

      A few years ago it was thought of as being beneficial for SEO to have masses of keyword rich content stuffed somewhere in your markup, but those days are gone. I’ve known people have their sites pulled for that in the past, but I’ve never heard of someone having a slapped hand for image replacement like we’ve done.

      Thanks for your input!

  • Pingback: 7 Responsive Navigation Patterns | Van SEO Design

  • http://www.physicsoflearning.com Doug Smith

    Hello,

    Thanks so much for these tutorials. They are amazing and a great resource for me.

    Are there any typical reasons why jquery scripts work on a local computer and Firefox on the web, but not when using ie or chrome? For example, I’ve worked out an html page that works on Firefox, but jquery such as flexslider do not work on chrome or ie.

    FWIW, I have your example website “Magazine” working on all three browsers. I believe my html page is very similar to yours (especially since this is how I’m learning!).

    example: http://www.physicsoflearning.com/590/index3.html

    Thanks,
    Doug

  • Michael

    Any way to make the drop down menu expand when longer links/titles are entered? Right now if you were to add a drop menu link called “yellow banana” under the Social menu the drop down menu would only be as wide as the parent “Social” link.

    Otherwise I’m loving the videos, been very helpful and insightful.

    • http://www.snaptin.com Ian Yates
      Author

      There is actually Michael… I should have looked into this myself. If you add the following CSS:

      nav.primary ul ul li a {
      white-space: nowrap;
      }
      

      then the submenu links will be prevented from wrapping (flowing to the next line when there’s no room). The whole thing will stretch out to the right. I’ve added this detail at the bottom of the tutorial – thanks for bringing it up!

      • Eric Larson

        Ian, this doesn’t work for me. It just leaves me with a horizontal scroll bar… Any way to fix this!?

  • ALEX S

    Ian,

    Thanks for putting these tut’s together.
    I am very new to webdesign, using Dreamweaver CS6 trial and have been following the tutorial step by step, however i can not seem to get the band images to pull into css when they do pull in they only appear in the develope page and not on live view or browser. Also the navigation wont work. If this a problem with cs6 or the skeleton??

    cheer

    Alex S

    • http://www.snaptin.com Ian Yates
      Author

      Hi Alex, Dreamweaver can be tricky as it often adds its own brand of styling and markup when you’re working in Design mode. Without seeing what you’ve done it’s difficult for me to comment, but by just sticking to the code view you’re much less likely to run into problems :)

  • Eoghan

    I have a question maybe someone can answer for me. Whats the reason for using the sprite image that way. Its it particularly advantageous to keep just one image with both logos and use that twice rather than create two separate images? Is it just a matter of caching or is there something else?

    • http://www.snaptin.com Ian Yates
      Author

      Hi Eoghan, there are a few benefits to using sprites over multiple images. Firstly, if built correctly, a sprite image will be much smaller in file size than the components collectively would be when split up. Secondly, a single image makes for a more organised project structure. Thirdly, and most importantly, using sprites reduces the amount of requests made to the server. Browsers can only make a limited (usually 2) number of simultaneous http requests, so pulling in multiple images can cause a queue to form.

      We have a detailed sprite usage tutorial planned, so stay tuned. Hope that answers your question!

      • Eoghan

        Ah ok, that certainly makes a lot of sense. I look forward to that tutorial.

        Thanks Ian.

  • Dan Fyles

    This is a very high quality tutorial indeed. Extremely good to work through – I have learned a great deal from this.
    I wonder if it is possible to prepend the dash for submenu items by adding to the javascript? I can do this using CSS for the main menu (not the dropdown) like this:

    nav.primary ul li ul a:before {
    		content: "\2014 \0020";
    		}

    but of course this does not affect the generated dropdown.

  • Pingback: Tutorials for Responsive Navigation Menus

  • Pingback: How to Give WordPress TwentyEleven a Mobile Navigation | Bowe

  • http://bowesales.com Jesse

    Hi Ian,

    I’ve found that adding a bit more javascript to the mobile navigation code will allow us to generate a dash instead of adding it to the markup itself and hiding it with css. Where you have //Populate dropdowns… replace it with this:

    // Populate dropdowns with dash for child pages
    $(".navigation nav li a").each(function() {
    var el = $(this);
    var padding = "";
    for (var i = 0; i < el.parentsUntil('div > ul').length - 1; i++)
    padding += "&ndash;";
    $("<option />", {
    "value"   : el.attr("href"),
    "html"    : padding + el.text(),
    }).appendTo("nav select");
    });
    

    You can always change out the – with other html such as   , » or whatever else you fancy. Let me know how this works out for you!

    • http://www.snaptin.com Ian Yates
      Author

      Nice job Jesse – much better than muddying up the markup – thanks for that!

    • http://www.facebook.com/geoffrey.barker.90 Geoffrey Barker

      Hi Jesse,

      Thanks for this. For reasons unknown, I couldn’t get Ian’s markup and CSS to work. It had the affect of clearing the sub menu items entirely. Rather than troubleshoot that code I tried your solution which is elegant and works nicely.

      A newby question though: In my implementation, I’m seeing 2 dashes (or double whatever I put in to the padding + statement… I don’t see any *2 type logic in your code so I’m wondering if it behaves that way for you too… and if so, how do it do that?

      I can post code if you like but I did a a straight cut and paste from your post so that doesn’t seem helpful somehow.

      I’m using Skeleton 1.2 and Jquery 1.7.1 if that’s germaine.

      Thanks a lot,

      Geoffrey

      • Jesse

        Hey Geoffrey,

        Try replacing the 1 with a 2 in the length variable:

        for (var i = 0; i ul').length - 1; i++)

        It seemed to work for me, but if you’ve found a different way, please share it!

  • Patrick

    I love CSS3 transitions and it always seems a shame to me that you can’t animate height if you use auto. I found a workaround to enable the menu dropdown to be animated in height, yet still apply the screen reader fix of height:0; & overflow:hidden; :

    1. in nav.primary ul ul, add a transition for max-height:

    , max-height 0.4s ease-out;

    2. set max-height just above height:0;

    max-height:0;

    3. in nav.primary ul li:hover ul add max-height:200px;

    Change 200px to the height of your tallest dropdown ul if you have one that is taller. The transition effect is being applied to 200px, so if you have a very small menu the height will appear to transition very quickly as the effect is always being applied at 200px, however it means you can still get quite a nice effect.

    I think it looks pretty good anyway :)

    Thanks for the great tutorial series!

    PS: You could even take things further in terms of accessibility by using methods discussed here: http://www.greywyvern.com/?post=337 I’ve used this on some of my projects and definitely prefer it to the menu instantly disappearing as soon you move your mouse even 1 pixel away from the menu (often accidentally).

    • Patrick

      Oops I forgot, just in case anyway actually wants to use this, to stop a scrollbar appearing during the transition just add:

      overflow-y:hidden;

      after overflow:hidden; on nav.primary ul li:hover ul

      I’ve been trying to work out how to apply the techniques on the greywyvern site without using visibility (to make it screen reader friendly) but I don’t think it’s possible without javascript. Oh well.

      • Patrick

        OK I realise I’m talking to myself, so I’ll probably start going crazy soon, but nevermind. I think I found a nice fix that has the UX benefits referred to in the greydawn blog and also animates the opacity and height when you mouseout of the ul. (I don’t know the code tag, apologies).

        nav.primary ul ul {

        /* height switched to max-height, and added a transition for max-height */

        opacity:0;
        filter: alpha(opacity=0);

        -webkit-transition: opacity 0.4s ease-out, max-height 0.4s ease-out;
        -moz-transition: opacity 0.4s ease-out, max-height 0.4s ease-out;
        -o-transition: opacity 0.4s ease-out, max-height 0.4s ease-out;
        -ms-transition: opacity 0.4s ease-out, max-height 0.4s ease-out;
        transition: opacity 0.4s ease-out, max-height 0.4s ease-out;

        position:absolute;
        z-index:999;
        background: url(../images/bg_bottom.png);
        min-width: 100%;
        max-height:0;
        overflow:hidden;
        box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
        }

        nav.primary ul li:hover ul{

        /* height:auto; removed. overflow not needed, set max-height to the tallest ul */

        opacity:1;
        filter: alpha(opacity=100);
        max-height:150px;
        }

  • Pingback: Design a Professional Blog Layout in Photoshop | JDesign's Blog

  • Pingback: Building a Responsive Layout With Skeleton : Widescreen | JDesign's Blog

  • Arthur

    Hello everyone,

    I can’t make appear the little dropdown select from chris coyier.
    I don’t know what’s wrong with my code, if someone could help me I’d be grateful.

    I think the error comes from this line:

    $("<select />").appendTo(".container nav");

    But I tried everything…

    Here’s a sample of my code:

    <body>
    	<div class="container">
        	<nav class="sixteen columns menu">
                <ul>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">Blog</a></li>
                    <li><a href="#">About</a></li>
                    <li><a href="#">Contact</a></li>
                </ul>
            </nav>
        </div>
    <!-- JS
    ================================================== -->
    	<!--chris coyier's little dropdown select-->
        <script type="text/javascript">
    		$(document).ready(function() {
                //build dropdown
    			$("<select />").appendTo(".container nav");
    		});
    	</script>
    </body>
    
  • Iva

    Thanks for your wonderful tutorial. I have used this menu.

    However, regardless of no-wrap, I get a scrollable submenu item. What could be wrong?

  • Fredrik

    Hi and thanks for a fantastic tutorial. It truly stands out for its detail and clarity.

    I too have the problem with the no-wrap on the submenu mentioned above by Iva. I’ve tried the no-wrap in a different design as well as in your source files, but despite this I still see the scrollbar.

    I use Safari 6.01, but see the same problem in Firefox 15.01. Grateful for any ideas.

    • http://www.snaptin.com Ian Yates
      Author

      Hi Frederick (and Iva) it’s always going to be difficult to diagnose when I don’t have the examples in front of my nose – any chance you can put something online for me to inspect? Thanks :)

  • Guest

    Hello and thank you very much for the intro to RWD and this tutorial is fantastic.

    I realize this was posted a little while ago, but Skeleton no longer comes with javascript in the zip file, so the javascript/tabs in the video “Responsive Navigation” is no longer easy to setup as you have shown.

    I tried this source code first – http://code.google.com/p/casa-simulacra/source/browse/trunk/simulacracities/war/javascripts/tabs.js?spec=svn2&r=2, but i couldnt get it to work, I then tried following the url i found under github https://raw.github.com/dhgamache/Skeleton/master/javascripts/tabs.js, but I get a 404, I guess it was deleted?

    Does anyone have the .js source code or have i overlooked it’s location via google? Thank you in advance!

    • ianyates

      You could always download the source files made available with this tutorial?!

      • http://www.facebook.com/mnowluck Nlm Naulak

        The source download gives me an error.

        • ianyates

          It certainly shouldn’t – try again? Or grab the source from one of the other tutorials in the series?

  • Jonathan

    I am curious as to the licensing of this tutorial. Can this be followed to create a “real” website, but with different logos and content? Thanks, this tutorial is AMAZING.

    • ianyates

      Technically speaking, you’re not permitted to directly use the source files for commercial use, but you’re encouraged to use the skills learned in following the tutorial for whatever you like. Glad you’ve enjoyed the tutorial :)

  • Mathias

    Hi Ian, great tutorial!
    On suggestion though – why not just prepend the submenu lines with jquery right away:

    // Populate dropdown with menu items
    $(".navigation nav li a").each(function() {
    var el = $(this);
    var pre = el.parents().get(2).tagName == "UL" ? "- " : "";
    $("", {
    "value" : el.attr("href"),
    "text" : pre + el.text()
    }).appendTo("nav select");
    });

    This way you can avoid the extra html/css markup ;)

    • ianyates

      Absolutely – you’re not the first to point that out either, something I should have thought of myself I guess! Thanks

  • Pingback: Quick Tip: Don’t Forget the optgroup Element | Webdesigntuts+

  • Pingback: Quick Tip: Don’t Forget the optgroup Element - Website Design Prices

  • Pingback: Quick Tip: Don’t Forget the optgroup Element - Цялостни IT решения,bussines 2 bussines,Оферти,Обяви,Работа, Коли под наем,Rent A Car ,Уеб Дизайн,nternet access, hosting, web design, network monitoring,

  • bobby

    How do I center the navigation in the primary nav div?

  • bobby

    Never mind

    nav.primary ul li {

    display: inline;

    position: relative;

    text-align: center;

    }

    :/ its late and im going to bed

  • Daniel Koch

    First of all, let me say that this tutorial is fantastic. I’m fairly new to web design, and this tutorial has helped me out a ton in designing my own responsive site.

    I’ve seen a couple of comments about issues with the CSS dropdown menu in IE8 (and possibly earlier?), but haven’t seen any solutions, so I thought I’d share what I’ve found and ask a couple of questions about it. The problem I had been seeing is that in the dropdown menu the hover states did not work correctly in IE8; the first menu item would stay highlighted but none of the others would highlight when you moused over them. It appears that the offending CSS attribute was the “filter: alpha(opacity=XX)” in the “nav.primary ul ul” and “nav.primary ul li:hover ul” selectors. To fix the problem I removed the following from “layout.css”:

    nav.primary ul ul {
    filter: alpha(opacity=0);
    }

    nav.primary ul li:hover ul {
    filter: alpha(opacity=100);
    }

    and then since the skeleton boilerplate adds a class of .ie to the html tag for IE8 and earlier, I added the following code to get the dropdown menu to work correctly in those browsers:

    .ie nav.primary ul ul {
    visibility: hidden;
    }

    .ie nav.primary ul li:hover ul {
    visibility: visible;
    }

    This appears to be working fine in IE8, but I haven’t been able to test it in earlier versions. I would assume it should work though since the visibility attribute is supported in earlier versions of IE? I also haven’t had a chance to test in IE9 to make sure it still works there, but I would still assume it should work since the opacity attribute is supported in this browser.

    So my questions are this: does this seem like a viable solution, and does anybody see any issues that might arise from taking this approach? Also, is using the “visibility” attribute appropriate in this case (it seems like the positioning shouldn’t be a problem since the submenu ul is has absolute positioning anyway), or would it be better to use the “display” attribute or something else entirely? Also, in general we’ve avoided using things like “display: none;” since it affects screen readers, but does the “visibility” attribute have that problem, or is it a non-issue since this rule only applies in IE8 and earlier and so wouldn’t affect screen readers anyway?

    Thanks for your help!

  • Peter Browne

    Hi

    Regarding the drop-down menus not displaying the full width of options text, the css in layout.css contains:

    nav.primary ul ul li a {
    display: block;
    line-height: 35px;
    text-transform: none;
    }

    Adding white-space: nowrap; makes no difference, tabs longer text is shown with a horizontal scroll bar. Is there a fix for this?

    • Liang

      I think the solution is to set submenu list min-width to be 100%. So when item name in main menu is short, the submenu item text will break the boundary with white-space: nowrap; When item name in main menu is long, the submenu width will be equal to it’s parent, perfect!

  • chris lewis

    What a fantastic tutorial for HTML5/CSS3 beginners like me !!

    I like many user comments here browse using Internet explorer 9 and also have the nav ul ul width scroll problem.
    I think its caused the layout.css primary nav code

    remove the ‘width: 100%;’ from the ‘nav.primary ul ul’ section.

    It now seems ok for me.

  • Peter Browne

    Aah thankyou, thankyou, thankyou Chris!!!

  • Jeffrey

    Hello, quick question.

    When I input the:

    //build dropdown

    $(“”).appendTo(“.navigation nav div”);

    I get an error “There is a syntax error on line 124. Code hinting may not work….”

    Any ideas? Would really appreciate. Thank you.

    Jeffrey

  • Jodi

    Hi, Ian

    I wanted to mention and share my fix for one odd thing that I found finishing up your excellent tutorial (nothing to do with your work, Safari is the culprit). Regarding the ‘One Last Point’ section, I added in the white-space:nowrap; css and it worked perfectly in Chrome and Firefox, but didn’t work in Safari, so i added in overflow:hidden; and it’s perfect on all three. I hope that this is helpful for anyone else :)

  • Jeffrey

    Hello,

    I have a header with logo and navigation together in one line and it works fine.

    My problem is I cannot get the logo to be clickable or become a link.

    Here is how I have it setup.

    HTML:

    Jeffrey Studio

    Graphic Design
    Workshops
    Studio
    Contact


    CSS:

    header.main {

    padding: 5px 0;

    }

    header h1.logo {

    margin:22px 0 0px 0;

    float: left;

    width: 100%;

    }

    header h1.logo a {

    padding: 10px 0 5px 0;

    height: 60px;

    display: block;

    background: url(../images/logo_reverse.png) no-repeat;

    font: 0/0 a;

    text-shadow: none;

    color: transparent;

    }

    header h1.letswork {

    margin:20px 0 0px 0;

    float: left;

    }

    /*navigation*/

    nav.primary ul,

    nav.primary ul li {

    margin: 10px;

    padding: 0px 0;

    font-size: 16px;

    }

    nav.primary ul ul li a {

    white-space: nowrap;

    }

    nav.primary select {

    display: none;

    width: 100%;

    height: 20px;

    margin: 21px 0;

    }

    nav.primary ul li {

    display: inline;

    float: left;

    position: relative;

    }

    nav.primary ul li a {

    display: inline-block;

    line-height: 49px;

    padding: 0 14px;

    color: #fff;

    text-transform: uppercase;

    text-decoration: none;

    font-weight: bold;

    letter-spacing: 0.08em;

    }

    nav.primary ul li a:hover {

    background: #00a79d;

    cursor: pointer;

    }

    nav.primary ul li a.active {

    background: #444;

    cursor: pointer;

    }

    Please help!!!!

  • http://www.vexinwebdesign.com/ @OuangDrak78

    Hi Ian ! Do I have to mention “great tuts” ;) ?

    A quick point scratch me :

    Sub Menu fonts are kind of blurry during one second and then are displayed neat.
    I often see that on themeforest wordpress themes.
    How to get rid of that ?
    Thanks for your answer :)

    • ianyates

      Which browser do you see that in? I expect what you’re talking about has to do with the way the submenu is rendered during its opacity transition. You could ditch the transition, that would probably help, or just speed it up perhaps. You could even change the type of transition. In any case, I reckon the transition is what’s causing the blurring (though I don’t see it in Chrome). Glad you’re enjoying the tuts :)