css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!--
The Menu will slide out right, displaying various options. Each of these options contains sub-menus that will slide-out below. Once a sub-menu is open, The main slide out(right) menu can be closed while the submenu is still displayed below.

Currently very js heavy.

Created by: William Goldsworthy.
-->

<DOCTYPE html>
<head> 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<div class='title'>
  <h3>Multi slide-out Navigation Menu with Sub-menus</h3>  
</div>
<div class='menu-bar'>
  <div class='circle'>
    <a class='menu-trigger text' href = '#'>OPEN</a>
  </div>
  <div class='option-one'>
    <div class='circle' id='option'>
    <a class='info text opt1' href = '#'>INFO</a>
    </div>
    <div class='sub-one1 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
  </div>
  <div class='option-two'>
    <div class='circle' id='option'>
    <a class='info text opt2' href = '#'>MENU</a>
    </div>
    <div class='sub-one2 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
     <div class='sub-two2 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
  </div>
  <div class='option-three'>
    <div class='circle' id='option'>
    <a class='info text opt3' href = '#'>COGS</a>
    </div>
    <div class='sub-one3 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
    <div class='sub-two3 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
    <div class='sub-three3 subCircle'>
    	<a class='subInfo' href='#'>SUB</a>
    </div>
  </div>
</div>
            
          
!
            
              h3 {
  position: absolute;
  display: block;
  left: 25%;
  margin-top: 1%;
  font-family: Century     Gothic,CenturyGothic,AppleGothic,sans-serif;
}

.menu-bar {
  display: block;
	position: absolute;
	top: 30%;
	left: 40%;
}

.menu-trigger {
  color: white;
  font-family: Century     Gothic,CenturyGothic,AppleGothic,sans-serif;
  text-decoration: none;
  position: absolute;
  left: 8px;
  top: 21px;
}

.circle {
  background-color: #0066FF;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  position: relative;
  text-align: center;
}

.subCircle {
  background-color: #0066FF;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  position: absolute;
  text-align: center;
}

.subInfo {
  color: white;
  font-family: Century        Gothic,CenturyGothic,AppleGothic,sans-serif;
  text-decoration: none;
  position: relative;
  top: 18px;
}

.sub-one1 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}

.sub-one2 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}

.sub-two2 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}

.sub-one3 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}
.sub-two3 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}
.sub-three3 {
  position: absolute;
  top: 8px;
  left: 5px;
  z-index: -4;
}

.info {
  color: white;
  font-family: Century        Gothic,CenturyGothic,AppleGothic,sans-serif;
  text-decoration: none;
  position: relative;
  top: 22px;
}

.option-one {
  position: absolute;
  top: 0px;
  left: 0px;
  z-index: -1;
}

.option-two {
  position: absolute;
  top: 0px;
  left: 0px;
  z-index: -2;
}

.option-three {
  position: absolute;
  top: 0px;
  left: 0px;
  z-index: -3;
}
            
          
!
            
              $(document).ready(function() {
	
	// This function is used to open the first menu. Slides out right.

	$('.menu-trigger').click(function() {
		if($('.option-one').hasClass('open') ) {
			$('.option-one').removeClass('open');
			$('.option-one').animate({left: "0px"}, 250 , 'swing')
			$('.option-one').css({"z-index": "-1"}); 
		}
		else
		{
			$('.option-one').addClass('open');
			$('.option-one').animate({left: "62px"}, 250 , 'swing', function() {
				$('.option-one').css({"z-index": "0"}); 
			});
		}
	});
	$('.menu-trigger').click(function() {
		if($('.option-two').hasClass('open') ) {
			$('.option-two').removeClass('open');
			$('.option-two').animate({left: "0px"}, 250 , 'swing')
			$('.option-two').css({"z-index": "-2"}); 
		}
		else
		{
			$('.option-two').addClass('open');
			$('.option-two').animate({left: "124px"}, 250 , 'swing', function() {
				$('.option-two').css({"z-index": "0"}); 
			});
		}
	});
	$('.menu-trigger').click(function() {
		if($('.option-three').hasClass('open') ) {
			$('.option-three').removeClass('open');
			$('.option-three').animate({left: "0px"}, 250 , 'swing')
			$('.option-three').css({"z-index": "-3"}); 
		}
		else
		{
			$('.option-three').addClass('open');
			$('.option-three').animate({left: "186px"}, 250 , 'swing', function() {
				$('.option-three').css({"z-index": "0"}); 
			});
		}
	});

	// This set of functions will only allow one sub menu to be open at any one time.

	$('.opt1').click( function() {
		if($('.sub-one1').hasClass('open') ) {
			closeOne();
		}
		else
		{
			openOne();
			toggleTwo();
			toggleThree();
		} 
	});

	$('.opt2').click(function() {
		if($('.sub-one2').hasClass('open') ) {
			closeTwo();
		}
		else
		{
			openTwo();
			toggleOne();
			toggleThree();
		}
	});

	$('.opt3').click(function() {
		if($('.sub-one3').hasClass('open') ) {
			closeThree();
		}
		else
		{
			openThree();
			toggleOne();
			toggleTwo();
		}
	});

	function closeOne() {
		$('.sub-one1').removeClass('open');
		$('.sub-one1').animate({top: "8px"}, 250 , 'swing');
	}

	function openOne() {
		$('.sub-one1').addClass('open');
		$('.sub-one1').animate({top: "62px"}, 250 , 'swing');
	}

	function toggleOne() {
		if($('.sub-one1').hasClass('open') ) {
			closeOne();
		}
		else
		{
			//Do nothing
		} 
	}

	function closeTwo() {
		$('.sub-one2').removeClass('open');
		$('.sub-one2').animate({top: "8px"}, 250 , 'swing');
		$('.sub-two2').removeClass('open');
		$('.sub-two2').animate({top: "8px"}, 250 , 'swing');
	}

	function openTwo() {
		$('.sub-one2').addClass('open');
		$('.sub-one2').animate({top: "62px"}, 250 , 'swing');
		$('.sub-two2').addClass('open');
		$('.sub-two2').animate({top: "114px"}, 250 , 'swing');
	}

	function toggleTwo() {
		if($('.sub-one2').hasClass('open') ) {
			closeTwo();
		}
		else
		{
			//Do nothing
		}
	}

	function closeThree() {
		$('.sub-one3').removeClass('open');
		$('.sub-one3').animate({top: "8px"}, 250 , 'swing');
		$('.sub-two3').removeClass('open');
		$('.sub-two3').animate({top: "8px"}, 250 , 'swing');
		$('.sub-three3').removeClass('open');
		$('.sub-three3').animate({top: "8px"}, 250 , 'swing');
	}

	function openThree() {
		$('.sub-one3').addClass('open');
		$('.sub-one3').animate({top: "62px"}, 250 , 'swing');
		$('.sub-two3').addClass('open');
		$('.sub-two3').animate({top: "114px"}, 250 , 'swing');
		$('.sub-three3').addClass('open');
		$('.sub-three3').animate({top: "166px"}, 250 , 'swing');
	}

	function toggleThree() {
		if($('.sub-one3').hasClass('open') ) {
			closeThree();
		}
		else
		{
			//Do nothing
		}
	}
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console