body {width: 90%; margin: 1em auto;}
/* The default, responsive menu, no JS scenario. */
nav a,
.nav-toggle {display: block; padding: .5em; margin: 0 0 .25em 0; background: #e5e5e5; border: 1px solid #ccc;}
/* Let's collapse that if we have JS */
.js-enabled nav {height: 0; overflow: hidden}
/* Then bring it back if we have JS and the toggle is clicked */
.js-enabled nav.active {height: auto;}
/* Now you can start laying on the fancy stuff, go! */
JavaScript
// Got js?
$("html").addClass("js-enabled");
// Do the menu stuff
$(function menuToggle() {
// Make a lovely nav toggle element
$('.menu').prepend('<a class="nav-toggle" href="#">Menu</div>');
// Give us a hook (.active) we can style when the toggle is clicked
$('.nav-toggle').click(function() {
$('nav').toggleClass('active');
return false;
});
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.