I've spent countless hours trying to troubleshoot an issue with my dropdown menu that expands whenever I hover over it. The bar stretches out to accommodate the list of dropdown contents and then reverts back to normal when I move my cursor away. My attempt to rectify this by setting the bar's position to absolute resulted in the navigation bar's elements being obscured by the background image. In a bid to prevent the bar from being hidden behind other page elements, I experimented with various z-index values (such as -1 for the background image and 10, 200, 999, etc., for the menu) but nothing seems to work! Even though I utilized W3 tools for the navbar, their classes do not specify z-values for any of the navbar's components or set the bar's position as static, leading me to believe the issue lies elsewhere. I am open to simpler construction suggestions if there are any.
HTML:
<!DOCTYPE html>
<html>
<title>Shop</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Fredoka One">
<link href="https://fonts.googleapis.com/css2?family=Mulish:wght@200&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bungee">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="preconnect" href="https://images.squarespace-cdn.com">
<body>
<!-- Navbar (sit on top) -->
<div class="w3-top">
<div class="w3-bar w3-white w3-wide w3-padding w3-card">
<a href="index.php" class="w3-bar-item w3-button logo">Logo</a>
<!-- Float links to the right. Hide them on small screens -->
<div class="w3-right w3-hide-small">
<div class="dropdown">
<button class="dropbtn w3-bar-item w3-button r-font">Shop A</button>
<div class="dropdown-content r-font">
...
Relevant CSS code:
p{
letter-spacing: 1px;
font-family: "Mulish";
text-align: center;
}
h3 {
letter-spacing: 1px;
font-family: "Mulish";
}
.r-logo {
letter-spacing: 1px;
font-family: "Fredoka One";
font-size: 62px;
color: #ffff99;
}
.w3-button.r-logo {
letter-spacing: 1px;
font-family: "Fredoka One";
font-size: 22px;
}
...