Fixed bottom nav with toggle display
by Trina Lu
HTML
<div class="page-wrapper">
<div class="pages">
</div>
<div class="pages">
</div>
<div class="pages">
</div>
<nav class="bottom-nav">
<ul>
<li>Top</li>
<li data-href="#works">Works</li>
<li data-href="#about">About</li>
</ul>
<div class="nav-body" id="works">
Works
</div>
<div class="nav-body" id="about">
About
</div>
</nav>
</div>
CSS
.page-wrapper {
position: absolute;
width: 100%;
top: 0;
left: 0;
}
.pages {
width: 100%;
height: 500px;
background: #009688;
}
.page-wrapper .pages:nth-child(2) {
background: #80CBC4;
}
.page-wrapper .pages:nth-child(3) {
background: #B2DFDB;
}
.bottom-nav {
position: fixed;
top: 100%;
width: 100%;
transform: translateY(-40px);
-webkit-transform: translateY(-40px);
-webkit-transition: all 0.3s ease-in;
}
.bottom-nav.open {
transform: translateY(-100%);
-webkit-transform: translateY(-100%);
}
.bottom-nav ul {
padding: 0;
margin: 0;
display: flex;
}
.bottom-nav ul li {
list-style-type: none;
flex-grow: 1;
-webkit-align-items: center;
align-items: center;
-webkit-justify-content: center;
justify-content: center;
text-align: center;
border: 1px solid #ffffff;
padding: 10px;
cursor: pointer;
background: #E91E63;
color: #FFF;
}
.nav-body {
width: 100%;
height: 200px;
background: #F48FB1;
}
JavaScript
$('.bottom-nav li').click(function(e) {
$('.bottom-nav').toggleClass('open');
});