Basic Sidebar Toggle Navigation with jQuery and CSS3 - Inception Menu

Basic Sidebar Toggle Navigation with jQuery and CSS3 - Inception Menu
File Size: 1.58 KB
Views Total:
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Inception Menu is a simple jQuery & CSS3 based siderbar navigation menu that is expandable and collapsible by clicking the toggle icon.

How to use it:

1. Create a sidebar navigation with a toggle button.

<div class="menu">
  <div class="line">
    <ul class="nav">
      <li>Home</li>
      <li>Products</li>
      <li>Blog</li>
      <li>Contact</li>
    </ul>
  </div>
  <i class="line"></i><i class="line"></i> 
</div>

2. The required CSS styles for the sidebar navigation.

*,
*:after,
*:before {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  font-weight: normal;
  margin: 0;
  outline: 0 none;
  padding: 0;
}

html,
body { height: 100%; }

.menu {
  cursor: pointer;
  padding: 15px;
  max-height: 100%;
  overflow: hidden;
  position:absolute;
}

.menu .line {
  height: 4px;
  display: block;
  width: 40px;
  background: #FFF;
  box-shadow: 0 1px 6px #000;
  margin: 10px;
  opacity: 1;
  transition: all 500ms ease;
}

.menu .line ul { list-style: none; }

.menu.active .line:nth-child(1) {
  height: 1000px;
  width: 250px;
  margin: -20px;
  box-shadow: 0 0 0 rgba(1, 1, 1, 0);
}

.menu.active .line:nth-child(2),
.menu.active .line:nth-child(3) { opacity: 0; }

.nav { padding: 20px; }

.menu:not(.active) .nav li {
  opacity: 0;
  margin-bottom: -10px;
}

.menu .nav li {
  opacity: 1;
  font-size: 16px;
  margin-bottom: 20px;
  transition: all 500ms ease;
}

3. Include the jQuery library at the end of the document.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 

4. Enable the sidebar navigation with a little jQuery magic.

$(document).ready(function() {
  $(".menu").click(function(){
    $(this).toggleClass("active");
  }); 
});

This awesome jQuery plugin is developed by 2ne. For more Advanced Usages, please check the demo page or visit the official website.