Skip to content

Instantly share code, notes, and snippets.

@Arquetipo28
Created October 9, 2019 08:16
Show Gist options
  • Save Arquetipo28/842c7a3b41a4bb2f189c2001099ab97e to your computer and use it in GitHub Desktop.
Save Arquetipo28/842c7a3b41a4bb2f189c2001099ab97e to your computer and use it in GitHub Desktop.
side-burguer-menu
body {
overflow: hidden;
margin: 0;
}
.side-menu {
position: absolute;
top: 0;
bottom: 0;
left: -300px;
width: 300px;
height: 100vh;
background-color: #E67E22;
transition: all 0.4s ease-out;
overflow-y: scroll;
}
.general-wrapper {
display: flex;
}
.container {
width: 100vw;
height: 100vh;
}
.nav-header {
height: 50px;
display: flex;
align-items: center;
font-family: 'Roboto', sans-serif;
}
.nav-company {
color: #909497;
}
.burguer-menu {
width: 50px;
display: flex;
justify-content: center;
margin: 0 15px;
font-size: 20px;
color: #E67E22;
}
#toggle-btn {
color: #E67E22;
}
#toggle-btn i {
color: #E67E22 !important;
}
a {
text-decoration: none;
}
/* On screens smaller than 1000px */
@media only screen and (min-width: 1000px) {
/* Fix side menu showing without pressing burguer button */
.side-menu {
position: fixed;
left: 0;
}
/*
It will take the width calculating the total width
subtracting px that are the total width of the side nav
*/
.container {
width: calc(100vw - 300px);
position: absolute;
right: 0;
}
.nav-header {
display: none;
}
}
.side-open {
left: 0;
}
.nav-wrapper {
padding: 0px 15px;
}
.nav-title {
color: #ECF0F1;
font-family: 'Roboto', sans-serif;
margin-bottom: 30px;
}
.nav-items {
padding: 0;
list-style-type: none;
overflow: hidden;
}
.nav-items li{
list-style: none;
color: #ECF0F1;
font-size: 16px;
font-family: 'Roboto', sans-serif;
padding: 12px 10px;
border-radius: 3px;
transition: all 0.5s;
}
.nav-items li:hover {
background-color: #EB984E;
}
.nav-active {
background-color: #AF601A;
}
.nav-icon {
margin: 0 10px;
}
var $sideMenu = $('#side-menu') // Id of the side container
// If user clicks on toggle-btn (the burguer button :D) it will toggle the class "side-open"
// which means that if "side-open" class is currently active on the selected element it will remove
// and in the same way the opposite
$('#toggle-btn').click(() => {
$sideMenu.toggleClass("side-open")
})
// When user clicks outside the side nav it will close
$(document).mouseup((e) => {
if ((!$sideMenu.is(e.target)) && $sideMenu.has(e.target).length === 0)
{
$sideMenu.removeClass("side-open")
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment