It's free and you have access to premium codes!
Welcome back! Please login to your account.
Don't worry, we'll send you a message to help you to recover your acount.
Please check your email for instructions to activate your account.
Written by 17 May 2020
If you have an important menu items but you thing that the items occupied the useful space of your website, use a collapse/expand button for your menu. When the menu is needed, visitors open it. When the items are not more useful, they can be collapsed into a small circular button.
<!-- this script is provided by https://www.javascriptfreecode.com coded by: Kerixa Inc. -->
<style>
body {
margin: 0;
padding: 0;
min-height: 100vh;
background-color: #dcdc39;
font-family: 'Open Sans', Verdana, Geneva, Tahoma, sans-serif;
}
body, .nav, .menu {
display: flex;
justify-content: center;
align-items: center;
}
.nav {
position: relative;
background-color: #fff;
padding: 20px;
transition: 0.5s;
border-radius: 50px;
overflow: hidden;
box-shadow: 0 8px 15px rgba(0,0,0,.2);
}
.menu {
margin: 0;
padding: 0;
width: 0;
overflow: hidden;
transition: 0.5s;
}
.nav input:checked ~ .menu {
width: 450px;
}
.menu li {
list-style: none;
margin: 0 10px;
}
.menu li a {
text-decoration: none;
color: #666;
text-transform: uppercase;
font-weight: 600;
transition: 0.5s;
}
.menu li a:hover {
color: #161919;
}
.nav input {
width: 40px;
height: 40px;
cursor: pointer;
opacity: 0;
}
.nav span {
position: absolute;
left: 30px;
width: 30px;
height: 4px;
border-radius: 50px;
background-color: #666;
pointer-events: none;
transition: 0.5s;
}
.nav input:checked ~ span {
background-color: #f974a1;
}
.nav span:nth-child(2) {
transform: translateY(-8px);
}
.nav input:checked ~ span:nth-child(2) {
transform: translateY(0) rotate(-45deg);
}
.nav span:nth-child(3) {
transform: translateY(8px);
}
.nav input:checked ~ span:nth-child(3) {
transform: translateY(0) rotate(45deg);
}
</style>
<div class="nav">
<input type="checkbox">
<span></span>
<span></span>
<div class="menu">
<li><a href="#">home</a></li>
<li><a href="#">about</a></li>
<li><a href="#">cursos</a></li>
<li><a href="#">blog</a></li>
<li><a href="#">contactos</a></li>
</div>
</div><a target='_blank' href='https://www.javascriptfreecode.com' style='font-size: 8pt; text-decoration: none'>JavaScript Best Codes</a>
Comments
Here you can leave us commments. Let us know what you think about this code tutorial!