My website has a vertical navigation bar with a breakpoint set for medium-sized screens to display a hamburger menu. When the hamburger menu appears, I want to hide the text following the icons to save space and only show the icons. Clicking on the hamburger menu should reveal the full menu again.
HTML
<nav class="navbar navbar-expand-md navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="nav navbar-sidenav">
<li class="nav-item">
<a class="nav-link nav-link-p" href="index.html"><i class="fas fa-tachometer-alt mr-4"></i>Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-p" href="users.html"><i class="fas fa-users mr-4"></i>Users</a>
</li>
<li class="nav-item">
<a class="nav-link nav-link-p" href="fatura.html"><i class="fas fa-users mr-4"></i>Admins</a>
</li>
</ul>
</div>
CSS:
.aside-section {
margin: 0;
float: left;
width: 280px;
height: 100%;
background-color: #f1f1f1;
}
.navbar-sidenav {
position: relative;
flex-direction: column;
width: 170px;
background-color: #f1f1f1;
}
.nav-link-p {
padding: 0;
margin: 28px 0 28px 10px;
}
@media screen and (max-width: 767.98px) {
/* Some code needs to be here */
}
I created a CodePen example demonstrating this functionality: https://codepen.io/ibrahim-kunushefci/pen/ewwWQv