|

Quick Tip: Use an Icon with Responsive-Nav.js an Icon Font

Responsive Nav is a really nifty (and light-weight) Javascript plugin that will allow you to easily create an off-canvas navigation menu that slides down from off the screen. Here’s a quick and easy way to use an icon instead of your run of the mill plain text.

In the examples for integrating Responsive Nav into your site, you’ll find several implementations of the clickable area used to reveal the menu (called the label) including the word, “Menu” and the common menu icon (commonly known as the ‘Hamburger’ icon). However, the latter requires some extra CSS and finagling to make it work. That’s not to say it’s hard, but it could be much easier with an icon font like Font Awesome.

Simply include the Font Awesome stylesheet on your site:

Then configure responsive-nav.js using the instructions here. Once you’re ready to call the script in your webpage (right before the </body> tag, as recommended), you can use this:

This will replace the default label (‘Menu’) with some markup to call the icon below, giving you a implementation with no hassle.

Screen Shot 2013-09-12 at 4.00.53 PM

Similar Posts

  • | |

    Manage Email Correspondence with GMail

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website!This seems like a silly title, since GMail is an email client and all. However, wouldn’t it be nice if you…

  • | | |

    Learning HTML and CSS (with My New Book, Out Now!)

    I’ve always been a learn-by-doing kind of guy. Maybe it’s because I’m thinking about other things when something is explained to me, or maybe people are bad at explaining things. But either way, a concept doesn’t really sink in until I do it, or until I see an immediate application for it. When I learned…

  • |

    Since the Last Time I Went to a Yankees Postseason Game

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! Since 1998, the last time I went to a Yankees Postseason game (Game 1 vs. the Texas Rangers in the…

  • |

    Simplecast Episodes Version 0.6

    Over the weekend I released Version 0.6 of my @simplecast plugin, Simplecast Episodes. Aside from some smaller internal changes, I added what I think is a pretty nice feature to coincide with WordPress 3.9’s new feature to create media playlists from audio and video: the ability to download episodes directly into WordPress, adding them to the…

  • | |

    The Yankees and the World Series

    Note: This article was published while I was in my early 20s. I was much younger and dumber. Please don’t hold it against me. One of the perils of having a 20+ year old website! Since the last time the Yankees went to the World Series in 2003 I’ve: Graduated college (MS and BS), started…

4 Comments

  1. This is a more elegant JavaScript solution than what I’ve done in the past. My only suggestion would be to use Font Awesome’s “icon-reorder” class as it displays the more common 3-line menu icon.

  2. Thanks! That is a great point; the 3-line menu is much more common.

    As a small (unrelated) addendum to this article, just a quick tip that if you float your menu items, opening the menu won’t work since you the height it technically 0. You’ll have to add the .group class or the .clearfix to fix it.

  3. Hi Joe,

    First of all: Thanks a lot for this post, it helped me a lot!

    I was wondering though if there is any way to make the Font Awesome “burger” more “tapable”. I find it very hard to open or close the reponsive nav on touch devices as you have to hit exactly one of the bars (not white space inbetween) for the nav to open/close.

    Tobi

  4. Tobi,

    Glad you liked it! I have noticed that too. I’d recommend playing with the font-size or padding to make it work a bit better.

    Joe

Comments are closed.