<!-- Forum question answer only:
https://www.sitepoint.com/community/t/help-my-menu-bar-is-not-sliding/354125/3 -->
<div class="wrapper">
<div class="container">
<h2>Tutor</h2>
<input type="checkbox" id="check">
<label for="check" class="checkbutton">
<i class="fas fa-bars">Menu</i>
</label>
<nav>
<ul>
<li><a class="active" href="#">Home</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Feedback</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Gallery</a></li>
</ul>
</nav>
</div>
</div>
/* =======================
general selector
======================= */
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body,
html {
height: 100%;
}
html {
font-size: 62.5%;
}
/* =======================
layout
======================= */
.wrapper {
width: 100%;
height: 8rem;
background: #000;
}
.container {
width: 90%;
height: 8rem;
margin: auto;
}
.container h2 {
font-size: 3.7rem;
color: white;
line-height: 8rem;
float: left;
margin: 0 4rem;
}
.container .checkbutton {
float: right;
font-size: 3.7rem;
line-height: 8rem;
margin: 0 3rem;
color: white;
display: none;
}
nav {
margin: 0;
padding: 0;
}
nav ul {
float: right;
}
nav li {
display: inline-block;
line-height: 8rem;
list-style: none;
}
nav a {
font-size: 1.8rem;
text-decoration: none;
color: white;
margin: 0 1.5rem;
text-transform: uppercase;
font-weight: bold;
padding: 0.3rem 0.6rem;
border-radius: 0.4rem;
}
nav a.active,
a:hover {
background: #32cd32;
}
#check {
display: none;
}
/* =======================
media queries
======================= */
@media only screen and (max-width: 904px) {
.container {
width: 100%;
}
.container h2 {
font-size: 3rem;
margin-left: 3rem;
}
nav a {
font-size: 2rem;
font-weight: bold;
color: black;
}
.container .checkbutton {
display: block;
cursor: pointer;
}
nav ul {
width: 100%;
height: 100vh;
position: fixed;
top: 8rem;
max-height:calc(100vh - 8rem);
overflow:auto;
text-align: center;
left: -100%;
transition: all 0.1s;
}
nav li {
display: block;
line-height: 10rem;
border-bottom: 1px solid gray;
}
nav a.active,
a:hover {
background: none;
color: grey;
}
#check:checked ~ nav ul {
left: 0;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.