Author: | Sums-shadow |
---|---|
Views Total: | 911 views |
Official Page: | Go to website |
Last Update: | December 27, 2021 |
License: | MIT |
Preview:

Description:
A creative and eye-catching hamburger navigation that reveals a sidebar menu by rotating the main content of the page.
How to use it:
1. Load the latest Font Awesome iconic font. Optional but recommended.
<link rel="stylesheet" href="/path/to/cdn/font-awesome/VERSION/css/all.min.css" />
2. Create a sidebar nav on the page.
<nav> <ul> <li><i class="fas fa-home"></i> Home</li> <li><i class="fas fa-user-alt"></i> Profile</li> <li><i class="fas fa-envelope"></i> Contact Us</li> </ul> </nav>
3. Create a hamburger button to toggle the sidebar nav.
<div class="container"> <div class="circle-container"> <div class="circle"> <button id="kanga"> <i class="fas fa-times"></i> </button> <button id="fongola"> <i class="fas fa-bars"></i> </button> </div> </div> <div class="content"> Main Content Here </div> </div>
4. The necessary CSS & CSS3 styles.
.container { background-color: #fafafa; transform-origin: top left; transition: transform 0.5s linear; width: 100vw; min-height: 100vh; padding: 50px; } .container.lakisa-menu { transform: rotate(-20deg); } .circle-container { position: fixed; top: -100px; left: -100px; } .circle { background-color: #0063b4; height: 200px; width: 200px; border-radius: 50%; position: relative; transition: transform 0.5s linear; } .container.lakisa-menu .circle { transform: rotate(-70deg); } .circle button { cursor: pointer; position: absolute; top: 50%; left: 50%; height: 100px; background: transparent; border: 0; font-size: 26px; color: #fff; } .circle button:focus { outline: none; } .circle button#fongola { left: 60%; } .circle button#kanga { top: 60%; transform: rotate(90deg); transform-origin: top left; } .container.lakisa-menu + nav li { transform: translateX(0); transition-delay: 0.3s; } nav { position: fixed; bottom: 40px; left: 0; z-index: 100; } nav ul { list-style-type: none; padding-left: 30px; } nav ul li { text-transform: uppercase; color: #fff; margin: 40px 0; transform: translateX(-100%); transition: transform 0.4s ease-in; } nav ul li i { font-size: 20px; margin-right: 10px; } nav ul li + li { margin-left: 15px; transform: translateX(-150%); } nav ul li + li + li { margin-left: 30px; transform: translateX(-200%); }
4. Rotate the main content to reveal the sidebar nav.
const fongola = document.getElementById('fongola') const kanga = document.getElementById('kanga') const container = document.querySelector('.container') fongola.addEventListener('click', () => container.classList.add('lakisa-menu')) kanga.addEventListener('click', () => container.classList.remove('lakisa-menu'))