Hey there! I am currently working on customizing the navigation menus in WordPress and here is the HTML code for the navigation menus:
<nav id="primary-navigation" class="site-navigation primary-navigation" role="navigation">
<h1 class="menu-toggle">Primary Menu</h1>
<a class="screen-reader-text skip-link" href="#content">Skip to content</a>
<div class="menu-primary-menu-container">
<ul id="menu-primary-menu" class="nav-menu">
<li id="menu-item-25" class="recipes menu-item menu-item-type-custom menu-item-object-custom menu-item-25"><a href="">Recipes</a></li>
<li id="menu-item-26" class="wine menu-item menu-item-type-custom menu-item-object-custom menu-item-26"><a href="">Wine</a></li>
<li id="menu-item-27" class="cocktails menu-item menu-item-type-custom menu-item-object-custom menu-item-27"><a href="">Cocktails</a></li>
</ul>
</div>
</nav>
Furthermore, the CSS code responsible for controlling the background color of the menu items upon hover is shown below:
.primary-navigation li:hover > a,
.primary-navigation li.focus > a {
background-color: #24890d;
color: #fff;
}
I have attempted to assign individual background colors to each menu item upon hover using the following CSS but it did not yield the desired results:
.primary-navigation .recipes li:hover > a,
.primary-navigation .recipes li.focus > a {
background-color: #e5ebd5;
color: #fff;
}
.primary-navigation .wine li:hover > a,
.primary-navigation .wine li.focus > a {
background-color: #8d89a1;
color: #fff;
}
.primary-navigation .cocktails li:hover > a,
.primary-navigation .cocktails li.focus > a {
background-color: #85b0ad;
color: #fff;
}
I would appreciate any guidance on what might be the issue with my approach and how I can achieve the desired outcome effectively.
Additionally, I am wondering if I need to remove the original CSS code that currently manages the background color on hover for all menu items or if there is a method to override it?
Thank you for your assistance,
Shyam Singh