Fullscreen Sliding Navigation Menu Plugin With jQuery - expandyMenu
File Size: | 21.9 KB |
---|---|
Views Total: | 2225 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
expandyMenu is a fancy jQuery navigation plugin used to create a fullscreen sliding menu that reveals the background on mouse hover.
How to use it:
1. Create the menu items as follows:
<div id="menu" class="menu-container"> <div id="item-1" class="menu-item red"> <h1>Menu 1</h1> <p>Description here</p> </div> <div id="item-2" class="menu-item blue"> <h1>Menu 2</h1> <p>Description here</p> </div> <div id="item-2" class="menu-item d-blue"> <h1>Menu 3</h1> <p>Description here</p> </div> <div id="item-3" class="menu-item green"> <h1>Menu 4</h1> <p>Description here</p> </div> <div id="item-4" class="menu-item yellow"> <h1>Menu 5</h1> <p>Description here</p> </div> </div>
2. Create a toggle link for the navigation menu.
<a class="cd-nav-trigger cd-text-replace" href="#primary-nav" id="toggle"> <span aria-hidden="true" class="cd-icon"></span> </a>
3. The primary CSS styles for the navigation menu.
#menu { overflow: hidden; } #menu>* { display: block; overflow: hidden; } .menu-item { width: 25%; height: 100%; display: block; position: absolute; float: left; -webkit-transform: translateY(-100%); transform: translateY(-100%); transition: transform 300ms linear; will-change: transform; pointer-events: auto; } .menu-item.active { -webkit-transform: translateY(0%); transform: translateY(0%); transition: transform 300ms linear; } h1 { font-size: 2.9vw; color: #ffffff; top: 15%; width: 260px; text-transform: uppercase; text-align: center; margin-left: -130px; left: 50%; z-index: 100; } .menu-item p { opacity: 0; text-align: center; margin-left: -130px; left: 50%; z-index: 100; top: 30%; width: 280px; color: #ffffff; -webkit-transition: opacity 0.5s, height 0.4s; -moz-transition: opacity 0.5s, height 0.4s; transition: opacity 0.5s, height 0.4s; } .menu-item.menu-expanded p { opacity: 1; } .menu-item>* { position: absolute; will-change: transform; } @media screen and (max-width: 768px) { .menu-horizontal .menu-item { width: 100%; float: none; position: relative; height: 250px; -webkit-transform: translateX(-100%); transform: translateX(-100%); transition: transform 300ms linear; } .menu-horizontal .menu-item.active { -webkit-transform: translateX(0%); transform: translateX(0%); transition: transform 300ms linear; } } .menu-item:after { content: ''; position: absolute; opacity: 0; top: 0; left: 0; height: 100vh; width: 100%; background-image: url("bg.jpg"); background-repeat: no-repeat; background-position: center center; background-size: cover; -webkit-transition: opacity 0.5s, height 0.4s; -moz-transition: opacity 0.5s, height 0.4s; transition: opacity 0.5s, height 0.4s; } .menu-item.menu-expanded:after { opacity: 1; -webkit-transform: scale(1); -moz-transform: scale(1); -ms-transform: scale(1); -o-transform: scale(1); transform: scale(1); }
4. Style the menu trigger.
.nav-trigger { position: absolute; z-index: 9999; top: 24px; right: 5%; height: 52px; width: 52px; border-radius: 50%; background-color: rgba(0, 0, 0, 0.8); -webkit-transition: background 0.2s; -moz-transition: background 0.2s; transition: background 0.2s; } .nav-trigger .nav-icon, .nav-trigger .nav-icon::before, .nav-trigger .nav-icon::after { /* menu icon created in CSS */ position: absolute; background-color: #ffffff; border-radius: 2px; /* Force Hardware Acceleration in WebKit */ -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; } .no-touch .nav-trigger:hover { background-color: black; } .nav-trigger .nav-icon { /* middle line of the menu icon */ display: inline-block; width: 18px; height: 2px; left: 50%; top: 50%; bottom: auto; right: auto; -webkit-transform: translateX(-50%) translateY(-50%); -moz-transform: translateX(-50%) translateY(-50%); -ms-transform: translateX(-50%) translateY(-50%); -o-transform: translateX(-50%) translateY(-50%); transform: translateX(-50%) translateY(-50%); -webkit-transition: -webkit-transform 0.3s, background-color 0.3s; -moz-transition: -moz-transform 0.3s, background-color 0.3s; transition: transform 0.3s, background-color 0.3s; } .nav-trigger .nav-icon::before, .nav-trigger .nav-icon::after { /* upper and lower lines of the menu icon */ content: ''; top: 0; right: 0; width: 100%; height: 100%; -webkit-transition: -webkit-transform 0.3s; -moz-transition: -moz-transform 0.3s; transition: transform 0.3s; } .nav-trigger .nav-icon::before { -webkit-transform: translateY(-6px); -moz-transform: translateY(-6px); -ms-transform: translateY(-6px); -o-transform: translateY(-6px); transform: translateY(-6px); } .nav-trigger .nav-icon::after { -webkit-transform: translateY(6px); -moz-transform: translateY(6px); -ms-transform: translateY(6px); -o-transform: translateY(6px); transform: translateY(6px); } .nav-trigger.project-open .nav-icon { /* user selects a projects - transform the icon into a 'X' */ background-color: rgba(255, 255, 255, 0); } .nav-trigger.project-open .nav-icon::before, .nav-trigger.project-open .nav-icon::after { background-color: white; } .nav-trigger.project-open .nav-icon::before { -webkit-transform: translateY(0) rotate(45deg); -moz-transform: translateY(0) rotate(45deg); -ms-transform: translateY(0) rotate(45deg); -o-transform: translateY(0) rotate(45deg); transform: translateY(0) rotate(45deg); } .nav-trigger.project-open .nav-icon::after { -webkit-transform: translateY(0) rotate(-45deg); -moz-transform: translateY(0) rotate(-45deg); -ms-transform: translateY(0) rotate(-45deg); -o-transform: translateY(0) rotate(-45deg); transform: translateY(0) rotate(-45deg); } .nav-trigger.nav-visible .nav-icon { /* user opens the navigation - transform the icon into an arrow */ -webkit-transform: translateY(-50%) translateX(-50%); -moz-transform: translateY(-50%) translateX(-50%); -ms-transform: translateY(-50%) translateX(-50%); -o-transform: translateY(-50%) translateX(-50%); transform: translateY(-50%) translateX(-50%); } .nav-trigger.nav-visible .nav-icon::after { -webkit-transform: translateX(5px) translateY(3px) rotate(-45deg) scaleX(0.5); -moz-transform: translateX(5px) translateY(3px) rotate(-45deg) scaleX(0.5); -ms-transform: translateX(5px) translateY(3px) rotate(-45deg) scaleX(0.5); -o-transform: translateX(5px) translateY(3px) rotate(-45deg) scaleX(0.5); transform: translateX(5px) translateY(3px) rotate(-45deg) scaleX(0.5); } .nav-trigger.nav-visible .nav-icon::before { -webkit-transform: translateX(5px) translateY(-3px) rotate(45deg) scaleX(0.5); -moz-transform: translateX(5px) translateY(-3px) rotate(45deg) scaleX(0.5); -ms-transform: translateX(5px) translateY(-3px) rotate(45deg) scaleX(0.5); -o-transform: translateX(5px) translateY(-3px) rotate(45deg) scaleX(0.5); transform: translateX(5px) translateY(-3px) rotate(45deg) scaleX(0.5); } @media only screen and (min-width: 1024px) { .nav-trigger.nav-visible .nav-icon { -webkit-transform: translateY(-50%) translateX(-50%) rotate(-90deg); -moz-transform: translateY(-50%) translateX(-50%) rotate(-90deg); -ms-transform: translateY(-50%) translateX(-50%) rotate(-90deg); -o-transform: translateY(-50%) translateX(-50%) rotate(-90deg); transform: translateY(-50%) translateX(-50%) rotate(-90deg); } .nav-trigger.nav-visible .nav-icon::after { -webkit-transform: translateX(-5px) translateY(3px) rotate(45deg) scaleX(0.5); -moz-transform: translateX(-5px) translateY(3px) rotate(45deg) scaleX(0.5); -ms-transform: translateX(-5px) translateY(3px) rotate(45deg) scaleX(0.5); -o-transform: translateX(-5px) translateY(3px) rotate(45deg) scaleX(0.5); transform: translateX(-5px) translateY(3px) rotate(45deg) scaleX(0.5); } .nav-trigger.nav-visible .nav-icon::before { -webkit-transform: translateX(-5px) translateY(-3px) rotate(-45deg) scaleX(0.5); -moz-transform: translateX(-5px) translateY(-3px) rotate(-45deg) scaleX(0.5); -ms-transform: translateX(-5px) translateY(-3px) rotate(-45deg) scaleX(0.5); -o-transform: translateX(-5px) translateY(-3px) rotate(-45deg) scaleX(0.5); transform: translateX(-5px) translateY(-3px) rotate(-45deg) scaleX(0.5); } }
5. Include jQuery library and the jQuery expandyMenu plugin at the bottom of the webpage. That's it.
<script src="//code.jquery.com/jquery.min.js"></script> <script src="jquery.expandyMenu.js"></script>
This awesome jQuery plugin is developed by Chilledson. For more Advanced Usages, please check the demo page or visit the official website.