I am currently designing a navigation bar where one category stands out with a different color (blue) compared to the rest (green). The functionality I'm aiming for is that when the cursor moves away from the blue HOME category, it should change back to green. Conversely, when hovering over any category, including HOME, it should turn blue, and revert to green once not hovered over. Here are some visual references:
Default/Home state: Users begin on the Home page with the Home category highlighted in blue.
Employer state: Users have navigated to the Employer Page, causing the Home category to switch to green.
Since I am using SFMC, all HTML, CSS, and JavaScript code must be contained separately. Below is the code snippet that I've implemented:
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
.body {
margin: 0;
font-family: Arial, Helvetica, sans-serif;
}
.topnav {
overflow: hidden;
background-color: #47a23f;
}
/* Rest of the CSS code remains unchanged */
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="topnav" id="myTopnav">
<a href="#home" class="active">Home</a>
<div class="dropdown">
<button class="dropbtn">Workforce
<i class="fa fa-caret-down"></i>
</button>
/* Remaining HTML code untouched */
</div>
// Closing tags omitted for brevity