Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStu Cowley
26,287 PointsHow Can I Create a Hamburger Menu?
Hi everyone,
I'm currently at the stage of a site that I'm building where I need a hamburger menu, and I'm having a tough time on how to actually create one. I have Googled and read many articles and I simply cannot find any resources on how to build a basic one from scratch using CSS, and JavaScript.
Can anyone suggest anywhere where I can find any tutorials and/or articles on how I can create a hamburger menu. I'm surprised this was never actually taught on this site.
Any advice on this would be greatly appreciated!
Thanks
Stu :)
4 Answers
Christopher Mlalazi
Front End Web Development Techdegree Graduate 17,305 PointsHave you done JavaScript and jQuery yet? If not, you can google open source and you will get various examples of code of the hamburger menu which you can fork and use, or learn from. Check codepen you can search for the hamburger menu there and this is what I got: http://codepen.io/search/pens?q=hamburger+menu&limit=all&type=type-pens
Ian Hazelton
6,187 PointsSometimes I'll use FontAwesome if other icons are needed in the project. It's quick and easy. Alternatively, It can be done in pure css. Type codepen+hamburger into google and you'll find thousands of examples. JS is optional i would say.
fngr
11,179 PointsI think you can't do this with CSS alone. You'll need JavaScript or jQuery ;)
Stu Cowley
26,287 PointsWhoops, forgot about JavaScript haha.
Chyno Deluxe
16,936 PointsHere is a quick menu I put together. While when I initially read the post. I thought you meant only creating the hamburger menu icon but readying it again I am assuming you want the menu in its entirety.
Here is a step in the right direction: jsFiddle Demo: Hamburger Menu Icon
While this doesn't include hiding and displaying of the menu itself, it is set up to do so with a little alteration of the javascript to your html and css.
I hope this helps.
Stu Cowley
26,287 PointsStu Cowley
26,287 PointsJust to mention also, I'm looking to display the menu when a user taps on the menu icon. Sorry I didn't add this to my post.
I'll include the code I'm using for my menu.
Just to point out also, this is using the Nav Menu that Guil Hernandez used in the Layout Basics course.