To make the dropdown menu functional, you should adjust the width of the elements to match the parent class ".dropdown". Each dropdown-content class should occupy 100% of the parent width. The parent dropdown class needs to have a position of relative, while the child content classes should be positioned absolutely. Specify the positioning of the dropdown inside the parent (e.g., 50px below the parent).
Below is a revised version that should work for your setup...
UPDATE: The "About" and "Contact Us" href links in your HTML had errors due to missing quotes. I also simplified the Javascript and CSS for better organization. While it can still be improved further, I've combined several elements and classes to illustrate the concept for you to refine.
Javascript:
function myFunction(ele) {
hideAll();
ele.nextElementSibling.style.display="block";
}
function hideAll() {
var dropdowns = document.getElementsByClassName("dropdown-content");
for (var i = 0; i < dropdowns.length; i++) {
dropdowns[i].style.display="none";
}
}
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
hideAll();
}
}
HTML:
<div class="navbar">
<div class=dropdown>
<button class="dropbtn btn1" value="About Us" onclick="window.location.href='https://uklivesound.000webhostapp.com/aboutus.html'">About Us</button>
</div>
<div class="dropdown">
<button class="dropbtn dropbtn1" onclick="myFunction(this)">Rehearsals</button>
<div class="dropdown-content" id="myDropdown1">
<a href="https://uklivesound.000webhostapp.com/liveroom.html">Live Room</a>
<a href="https://uklivesound.000webhostapp.com/isolationroom.html">Isolation Room</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn dropbtn2" onclick="myFunction(this)">Recording</button>
<div class="dropdown-content" id="myDropdown2">
<a href="https://uklivesound.000webhostapp.com/audiorecording.html">Audio</a>
<a href="https://uklivesound.000webhostapp.com/videorecording.html">Video</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn dropbtn3" onclick="myFunction(this)">For Hire</button>
<div class="dropdown-content" id="myDropdown3">
<a href="https://uklivesound.000webhostapp.com/hirepackages.html">Event Packages</a>
<a href="https://uklivesound.000webhostapp.com/largeevents.html">Large Events</a>
<a href="https://uklivesound.000webhostapp.com/equipmenthire.html">Equipment</a>
<a href="https://uklivesound.000webhostapp.com/bandhire.html">Bands</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn dropbtn4" onclick="myFunction(this)">Other Services</button>
<div class="dropdown-content" id="myDropdown4">
<a href="https://uklivesound.000webhostapp.com/buyandsell.html">Buy & Sell</a>
<a href="https://uklivesound.000webhostapp.com/repairs.html">Repairs</a>
</div>
</div>
<div class=dropdown>
<button class="dropbtn btn2" value="Contact Us" onclick="window.location.href='https://uklivesound.000webhostapp.com/contact.html'">Contact Us</button>
</div>
</div>
CSS:
.navbar {
float:left;
font-family:Impact, Haettenschweiler, Franklin Gothic Bold, Arial Black,sans-serif;
height:auto;
width:100%;
display:inline-block;
margin:0;
padding:0;
position:relative;
}
.navbar a { font-size: 2em; font-weight: 100;
color: white;
text-align: center; }
.dropdown {
position: relative;
float:left;
width:16%;
}
.dropdown-content {
display: none;
position: absolute;
top: 50px;
background-color: #f9f9f9;
width:100%;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
padding:0px;
height:auto;
}
.dropdown-content a {
text-decoration: none; text-align:center; height:auto;
display: block; width:100%; padding:0px; background-color:#000000; border: 1px solid white;
}
.dropdown-content a:hover {
color: black;
padding: 12px 16px;
text-decoration: none; text-align:center; height:auto;
display: block; width:100%; background-color:#FFFFFF; border: 1px solid black;
font-family:Impact, Haettenschweiler, Franklin Gothic Bold, Arial Black,sans-serif;
transition-duration:0.5s; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2)
}
.dropbtn {
color: white;
padding:0px; margin:0px;
font-size:2em;
border: 1px solid white;
cursor:pointer; width:100%; float:left;
}
.dropbtn:hover, .dropbtn:focus {
background-color:#FFFFFF;
color: black;
border: 1px solid black;
font-family:Impact;
transition-duration:0.5s;
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
}
.btn1 {
background-color:#71aace;
}
.btn2 {
background-color:#D84E92;
}
.dropbtn1 {
background-color:#6c73b1;
}
.dropbtn2 {
background-color:#d3c530;
}
.dropbtn3 {
background-color:#82c845;
}
.dropbtn4 {
background-color:#8f65a1;
}