<h3 id="menu-toggle">Menu</h3>
<ul id="menu">
  <li><a href="#">Home</a>
    <ul class="sub-menu">
      <li><a href="#">Test 1</a></li>
      <li><a href="#">Test 2</a></li>
  <li><a href="#">Products</a>
    <ul class="sub-menu">
      <li><a href="#">HTML</a></li>
      <li><a href="#">CSS</a></li>
      <li><a href="#">Javascript</a>
        <ul class="sub-menu">
          <li><a href="#">jQuery</a></li>
          <li><a href="#">MooTools</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Contact</a></li>           
#menu, .sub-menu {
  display: none;
  list-style: none;

/*Change toggle size by adjusting width & height*/
.tb-menu-toggle {
  border: 0;
  position: relative;
  background: transparent;
  cursor: pointer;

/*Change toggle color here*/
.tb-menu-toggle i {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 20%;
  -webkit-transition:all .2s;
   -moz-transition:all .2s;
     -o-transition:all .2s;
        transition:all .2s;
.tb-menu-toggle i:nth-child(2) {
  top: 40%;
.tb-menu-toggle i:nth-child(3) {
  top: 80%;

/* Style the active toggle here */
.tb-menu-toggle.tb-active-toggle i {  }

/*Animation of the toggle*/
.tb-menu-toggle.tb-animate-toggle i:first-child,
.tb-menu-toggle.tb-animate-toggle i:nth-child(2){ 
  top: 40%;
.tb-menu-toggle.tb-animate-toggle i:nth-child(3){ 
  top: 40%;
  // Define the threeBarToggle function by extending the jQuery object
  threeBarToggle: function(options){
    // Set the default options
    var defaults = {
      color: 'black',
      width: 30,
      height: 25,
      speed: 400,
      animate: true
    var options = $.extend(defaults, options); 
    return this.each(function(){
      $(this).empty().css({'width': options.width, 'height': options.height, 'background': 'transparent'});
      $(this).prepend('<i></i><i></i><i></i>').on('click', function(event) {
        if (options.animate) { $(this).toggleClass('tb-animate-toggle'); }
      $(this).children().css('background', options.color);
  // Define the accordionMenu() function that adds the sliding functionality
  accordionMenu: function(options){
    // Set the default options
    var defaults = {
      speed: 400
    var options =  $.extend(defaults, options);

    return this.each(function(){
      var menuItems = $(this).children('li');
      $('.tb-parent ul').hide();
      $('.tb-parent > a').on('click', function(event) {

// Convert any element into a three bar toggle
// Optional arguments are 'speed' (number in ms, 'slow' or 'fast') and 'animation' (true or false) to disable the animation on the toggle
$('#menu-toggle').threeBarToggle({color: 'green', width: 30, height: 25});

// Make any nested ul-based menu mobile
// Optional arguments are 'speed' and 'accordion' (true or false) to disable the behavior of closing other sub
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. //cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js