Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

hamburger menu js

h1
{
color:green;
}
body {
height: 100px;
padding: 0;
margin: 0;
overflow: hidden;
}
.navigation {
max-width: 500px;
border-radius: 8px;
background-color: white;
padding-right: 30px;
line-height: 3;
display: flex;
}
.navigationBar {
position: relative;
width: 100%;
height: 100%;
}
.navigationBar::before, .navigationBar::after {
width: 100%;
height: 50%;
background-color: #EAFBFF;
}
*, *::before, *::after {
box-sizing: border-box;
}
.navigationBar.active ul {
width: 420px;
margin-right: 20px;
}
.navigationToggle {
width: 40px;
height: 48px;
padding: 14px 5px;
cursor: pointer;
}
.navigationBar ul {
display: flex;
justify-content: space-between;
list-style: none;
width: 0;
overflow: hidden;
}
.navigationBar:not (.active ) .navigationToggle {
margin-left: -11px;
}
.navigationToggle::after {
margin-top: 10px;
}
.navigationBar.active .navigationToggle::before, .navigationBar.active .navigationToggle::after
{
position: absolute;
top: 52%;
transform: rotate(135deg);
}
.navigationToggle::before, .navigationToggle::after {
content: '';
position: relative;
display: block;
width: 30px;
height: 3px;
background-color: red;
}
.navigationBar.active .navigationToggle::after {
transform: rotate(-135deg);
margin-top: 0;
}
JavaScript Code: HamburgerMenu.js
let navWrapper = document.querySelector('.navigationBar'), navToogler = document
.querySelector('.navigationToggle')
navToogler.addEventListener('click', function(event) {
navWrapper.classList.toggle('active')
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: Document object not defined Next js 
Javascript :: angular js 
Javascript :: Geometery parsing GeoJSON 
Javascript :: js array modify element 
Javascript :: get last item in array js 
Javascript :: express router 
Javascript :: add to json object javascript 
Javascript :: dom in javascript 
Javascript :: define function js 
Javascript :: understanding currying 
Javascript :: arrow function in javascript 
Javascript :: basic area chart 
Javascript :: fs.readfilesync withFileTypes true 
Javascript :: Uncaught ReferenceError: function is not defined 
Javascript :: how to count characters 
Javascript :: Plugin "react" was conflicted between "package.json » eslint-config-react-app 
Javascript :: what is a blob in javascript 
Javascript :: scribbletune 
Javascript :: express request url ignores hash 
Javascript :: jmathplot 
Javascript :: window.location.href breaks back button 
Javascript :: js let vs var performance 
Javascript :: npm i react-router semantic-ui-react semantic-ui-css 
Javascript :: react-resizable-rotatable-draggable 
Javascript :: javascript generator send vs next 
Javascript :: how to program in javascript and jquery on a page 
Javascript :: Return a sorted array without mutating the original array JS Javascript Free Code Camp FCC 
Javascript :: how to make random responses 
Javascript :: node command get to much time 
Javascript :: unit test for dynamodb query is a function 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =