-1
I built a custom sidebar for my dashboard. Inside this sidebar, I have some menu items. When my screen is small, I make all menu options disappear, and show you a specific menu option. This specific menu option is used as a button that causes all menu items to appear again.
My sidebar:
When my screen is small, the sidebar looks like this:
To mount the sidebar I use the code below:
<div class="card-body">
<a id="shmenulinks" class="nav-link" style="border-radius: 0.25rem; cursor: pointer; width: 100%;" data-toggle="collapse" aria-expanded="true" aria-controls="menulinks" data-target="#menulinks"><i class="fa fa-bars" aria-hidden="true"></i> Open/Close menu</a>
<div id="menulinks" class="nav nav-pills" >
<a style="width: 100%;" href="https://codepen.io/" target="blank" class="nav-link "><i class="fa fa-home" aria-hidden="true"></i> Home</a>
<a style="width: 100%;" href="https://codepen.io/" target="blank" class="nav-link "><i class="fa fa-line-chart" aria-hidden="true"></i> Projects</a>
<a style="width: 100%;" href="https://codepen.io/" target="blank" class="nav-link "><i class="fa fa-suitcase" aria-hidden="true"></i> Jobs</a>
<a style="width: 100%;" href="https://codepen.io/" target="blank" class="nav-link "><i class="fa fa-sign-out" aria-hidden="true"></i> Logout</a>
</div>
</div>
To make the items appear/disappear I use this CSS logic below:
@media screen and (min-width: 992px) {
#shmenulinks {
display: none;
}
#menulinks {
display: block;
}
}
@media screen and (max-width: 991px) {
#shmenulinks {
display: block;
}
#menulinks {
display: none;
}
}
My problem is when the screen is small and the menu collapsed, the button I use to make the menu items appear again does not work.
THE CODEPEN: https://codepen.io/neyelson-alves/pen/ZEGbdJB
What should I do?