Skip to content

Instantly share code, notes, and snippets.

@joaohcrangel
Created June 30, 2020 02:03
Show Gist options
  • Save joaohcrangel/e5d78550c71fc2f3864ce251bb87ff20 to your computer and use it in GitHub Desktop.
Save joaohcrangel/e5d78550c71fc2f3864ce251bb87ff20 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hcode Menu</title>
<style>
body {
margin: 0;
width: 100%;
overflow: hidden;
position: relative;
}
#menu {
background-color: black;
color: azure;
position: fixed;
right: -300px;
top: 0;
width: 300px;
height: 100vh;
transition-duration: .5s;
}
#menu.open {
right: 0;
}
#menu ul {
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
}
#menu ul li {
list-style: none;
padding: 10px 0;
}
@media (min-width: 992px) {
#menu {
background-color: azure;
color: initial;
width: 100%;
height: initial;
right: initial;
}
#menu ul {
flex-direction: row;
height: 50px;
}
}
</style>
<body>
<button type="button" id="btn-menu">Menu</button>
<nav id="menu">
<ul>
<li>Home</li>
<li>Quem Somos</li>
<li>Contato</li>
</ul>
</nav>
<script>
document.querySelector('#btn-menu').addEventListener('click', e => {
document.querySelector('#menu').classList.toggle('open');
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment