Modern Overlay Side Navigation With jQuery And CSS3 - Techie Menu
File Size: | 4.33 KB |
---|---|
Views Total: | 6521 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |

A modern, translucent, semantic, multi-level, off-canvas navigation with a hamburger toggle button that covers part of the page when toggled.
Built using jQuery, HTML unordered list, and CSS3 transitions & transforms.
How to use it:
1. Create the HTML for the overlay navigation.
<div class="navigation"> <div class="toggle-wrapper"> <span class="show">☰</span> <span class="hide">⚊</span> </div> <div class="heading">Site Logo</div> <ul class="menu"> <li><a href="#!">Home</a></li> <li class="active"><a href="#!">Blog</a></li> <li class="has-menu"> <a href="#!">Category</a> <ul class="menu"> <li><a href="#!">jQuery</a></li> <li><a href="#!">HTML5</a></li> <li><a href="#!">CSS/CSS3</a></li> </ul> </li> <li><a href="#!">Contact</a></li> <li><a href="#!">About</a></li> </ul> </div>
2. The necessary CSS/CSS3 styles.
.navigation { border: 1px solid rgba(255,255,255,0.1); height: 100%; width: 320px; background-color: rgba(255,255,255,0.1); color: #fff; position: fixed; z-index: 9999; top: 0; right: calc(100% - 320px); transition: right 0.5s; } .navigation .heading { padding: 15px; height: 51px; border-bottom: 1px solid rgba(255,255,255,.1); line-height: 20px; } .navigation .menu { list-style-type: none; } .navigation .menu li { border-bottom: 1px solid rgba(255,255,255,0.1); } .navigation .menu a { display: block; padding: 15px; line-height: 20px; color: #fff; text-decoration: none; position: relative; z-index: 0; } .navigation .menu a::after { content: ''; background-color: rgba(255,255,255,0.1); position: absolute; top: 0; right: 100%; bottom: 0; left: 0; transition: left 0.25s, right 0.25s; } .navigation .menu a:hover::after { right: 0; } .navigation .has-menu { position: relative; } .navigation .has-menu::before { content: ''; border-left: 1px solid rgba(255,255,255,0.1); height: 50px; width: 50px; cursor: pointer; position: absolute; top: 0; right: 0; z-index: 1; } .navigation .has-menu::after { content: '\027A4'; padding: 15px 0; height: 50px; width: 50px; line-height: 20px; text-align: center; cursor: pointer; position: absolute; top: 0; right: 0; z-index: 1; transform: rotate(90deg); transition: transform 0.25s; } .navigation .has-menu > .menu { overflow: hidden; max-height: auto; } .navigation .menu .menu { border-top: 1px solid rgba(255,255,255,0.1); } .navigation .has-menu > .menu > li > a { padding-left: 45px; transition: padding 1s; } .navigation .has-menu > .menu > li:last-child { border-bottom: none; } /* Closed States */ .navigation:not(.open) { right: 100%; } .navigation:not(.open) .toggle-wrapper .show { right: 0px; } .navigation:not(.open) .toggle-wrapper .hide { right: 50px; } .navigation .has-menu:not(.open)::after { transform: rotate(-90deg); } .navigation .has-menu:not(.open) > .menu { border-top: none; max-height: 0; } .navigation .has-menu:not(.open) > .menu > li > a { padding-left: 15px; }
3. The CSS rules for the hamburger toggle button.
.navigation .toggle-wrapper { border: 1px solid rgba(255,255,255,0.1); border-left: none; height: 52px; width: 51px; background-color: rgba(255,255,255,0.1); overflow: hidden; position: absolute; top: -1px; right: calc(0px - 52px); } .navigation .toggle-wrapper span { width: 50px; height: 50px; line-height: 50px; text-align: center; background-color: transparent; color: inherit; cursor: pointer; position: absolute; top: 0; right: 0; transition: right 0.25s; } .navigation .toggle-wrapper .show { right: -50px; }
4. Include the required jQuery library at the bottom of the webpage.
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
5. The main JavaScript (jQuery script) to toggle CSS classes based on the current state of the navigation.
$(function(){ $('.navigation .toggle-wrapper .show').on('click',function(){ $('.navigation').addClass('open'); }); $('.navigation .toggle-wrapper .hide').on('click',function(){ $('.navigation').removeClass('open'); }); $('.navigation .has-menu a').on('click',function(e){ e.stopPropagation(); }); $('.navigation .has-menu').on('click',function(){ $(this).toggleClass('open'); }); });
This awesome jQuery plugin is developed by RedYetiCo. For more Advanced Usages, please check the demo page or visit the official website.