Navbar - change from scroll to click?
I have a navigation bar on a website I am building and have I noticed that it is notoriously difficult to navigate on mobile devices due to the navbar menu options opening and closing based on scrolling on and off of them. Is there way I can essentially easily convert the functionality to open and close via clicking rather than scrolling?
It is a navbar made using a ul from scratch not using Bootstrap.
I would provide a link however the hosting site I am using is experiencing problems for free users and the site cannot be viewed currently online.
HTML:
<div id="navbar">
<nav>
<meta charset="utf-8">
<ul>
<li><a href="https://uklivesound.000webhostapp.com/aboutus.html">About Us</a></li>
<li><a>Rehearsals</a>
<ul>
<li><a href="https://uklivesound.000webhostapp.com/liveroom.html" class="sub">Live Room</a></li>
<li><a href="https://uklivesound.000webhostapp.com/isolationroom.html" class="sub">Isolation Room</a></li>
</ul>
</li>
<li><a>For Hire</a>
<ul>
<li><a href="https://uklivesound.000webhostapp.com/hirepackages.html" class="sub">Event Packages</a></li>
<li><a href="https://uklivesound.000webhostapp.com/largeevents.html" class="sub">Large Events</a></li>
<li><a href="https://uklivesound.000webhostapp.com/equipmenthire.html" class="sub">Equipment</a></li>
<li><a href="https://uklivesound.000webhostapp.com/bandhire.html" class="sub">Bands</a></li>
</ul>
</li>
<li><a>Recording</a>
<ul>
<li><a href="https://uklivesound.000webhostapp.com/audiorecording.html" class="sub">Audio</a></li>
<li><a href="https://uklivesound.000webhostapp.com/videorecording.html" class="sub">Video</a></li>
</ul>
</li>
<li><a>Other Services</a>
<ul>
<li><a href="https://uklivesound.000webhostapp.com/buyandsell.html" class="sub">Buy/Sell</a></li>
<li><a href="https://uklivesound.000webhostapp.com/repairs.html" class="sub">Repairs</a></li>
</ul>
</li>
<li><a href="https://uklivesound.000webhostapp.com/contact.html">Contact Us</a></li>
</ul>
</nav>
</div>
CSS
#navbar * {
-webkit-text-size-adjust: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
margin: 0;
position: relative;
z-index:20;
}
body {background-color:#79c5f4;}
nav ul { list-style:none;
}
li:nth-child(1) {background-color:#71aace;}
li:nth-child(2) {background-color:#6c73b1;}
li:nth-child(3) {background-color:#d3c530;}
li:nth-child(4) {background-color:#82c845;}
li:nth-child(5) {background-color:#8f65a1;}
li:nth-child(6) {background-color:#d84e92;}
li:nth-child(7) {background-color:#444080;}
nav ul li {
display:block;
float:left;
text-align:center;
width:16.667%;
position: absolute;
z-index:11;
}
nav ul li:hover {background-color:white;}
nav a {
display:block;
height:100%;
font-family:'Impact', sans-serif;
font-size:2.0vw;
color:white;
text-decoration:none;
color:white;
position: relative;
z-index:9;
}
nav ul li ul {display:none;}
nav ul li:hover ul {display:block;}
nav ul li:hover :first-child:not(.sub) {color:black;}
nav ul li ul li {
float:none;
width:100%;
position: absolute;
z-index:10;
}
nav .sub:hover {color:black;}
Thanks!
