7
I have a menu hamburguer
which opens from left to right however, I would like it to open backwards, from right to left, as I do this?
Next down my code:
/*
* Open the drawer when the menu ison is clicked.
*/
var menu = document.querySelector('#menu');
var main = document.querySelector('main');
var drawer = document.querySelector('#drawer');
menu.addEventListener('click', function(e) {
drawer.classList.toggle('open');
e.stopPropagation();
});
main.addEventListener('click', function() {
drawer.classList.remove('open');
});
html, body {
height: 100%;
width: 100%;
margin: 0px;
}
a#menu svg {
width: 40px;
fill: #000;
}
nav, main {
padding: 1em;
box-sizing: border-box;
}
main {
width: 100%;
height: 100%;
}
#drawer {
background-color: rgba(219, 219, 224, 0.27);
}
#menu {
float: right
}
/*
* Off-canvas layout styles.
*/
/* Since we're mobile-first, by default, the drawer is hidden. */
nav {
width: 250px;
height: 100%;
position: absolute;
/* This trasform moves the drawer off canvas. */
-webkit-transform: translate(-450px, 0);
transform: translate(-450px, 0);
/* Optionally, we animate the drawer. */
transition: transform 0.3s ease;
}
nav.open {
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
}
<body>
<nav id="drawer" class="dark_blue">
<ul>
<a href="http://www.ufrgs.br/termisul/">Home</a>
<a href="http://www.ufrgs.br/termisul/termisul/">Termisul</a>
<a href="http://www.ufrgs.br/termisul/equipe-termisul/">Equipe</a>
<a href="http://www.ufrgs.br/termisul/contato/">Contato</a>
</ul>
</nav>
<main class="light_blue">
<a id="menu">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M2 6h20v3H2zm0 5h20v3H2zm0 5h20v3H2z"/>
</svg>
</a>
</main>
</body>
I believe that it is better to use the editor that the OS provides itself, not being necessary to open another page to view the code working.
– Felipe Paetzold
@Felipepaetzold Thank you for the suggestion, amended answer.
– Diego Vieira