Adjust Nav Element Colors When Hovered Over Using CSS

How can I make the "brand-logo" and all the li's on the right side of the nav change to black when hovering over the nav itself? The nav already changes to #FFF on hover:

Check out this CodePen for reference

Here is the HTML snippet:

<nav id="nav">
  <div class="nav-wrapper">
    <span id="logo-container" class="brand-logo">Example</span>
    <div>
      <ul class="right">
        <li class="active"><a href="/">About</a></li>
        <li><a href="/contact">Contact</a></li>
        <li><a href="/portfolio">Portfolio</a></li>
        <li><a href="/resume">Resume</a></li>
        <li><a class="waves-effect email-btn" href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cda8b5aca0bda1a88daaa0aca4a1e3aea2a0">[email protected]</a>">email me</a></li>
      </ul>
    </div>
  </div>
</nav>

And the CSS code:

body {
  background-color: #222;
}

nav:hover {
  background: #fff;
  -webkit-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  transition: all 0.5s ease;
  color: #222;
}

nav .nav-wrapper {
  position: relative;
  height: 100%;
}

nav {
  background: transparent;
  -webkit-box-shadow: none;
  box-shadow: none;
  color: #fff;
  width: 100%;
  height: 90px;
  line-height: 56px;
  display: block;
}

nav .brand-logo {
  position: absolute;
  color: #fff;
  display: inline-block;
  font-size: 2.1rem;
  padding: 0;
  white-space: nowrap;
}

nav ul li.active {
  background-color: rgba(0, 0, 0, 0.1);
}

nav ul a:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

nav ul li {
  transition: background-color 0.3s;
  float: left;
  padding: 0;
}
nav ul a {
  transition: background-color 0.3s;
  font-size: 1rem;
  color: #fff;
  display: block;
  padding: 0 15px;
  cursor: pointer;
}

.right {
  float: right;
}
ul:not(.browser-default) {
  padding-left: 0;
  list-style-type: none;
}
.email-btn {
  background: transparent;
  border: 1px solid #fff;
  border-radius: 20px;
}
.waves-effect {
  position: relative;
  cursor: pointer;
  display: inline-block;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  vertical-align: middle;
  z-index: 1;
  transition: 0.3s ease-out;
}

I have attempted adding "color: #222" to nav:hover, but it doesn't affect the text in the nav. Any suggestions are appreciated!

Thank you for your assistance!

Answer №1

Here is a possible solution:

nav:hover #logo-container, nav:hover ul li a {
  color: #000;  
}

This code will change the text color to black for the #logo-container and links within the navigation when a user hovers over it.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What could be causing this SVG with CSS animation to appear cropped only in Firefox?

The SVG animation in the hero section of this webpage appears to be cropped only on Firefox. Despite trying a jQuery solution to force the size of the SVG to match the window dimensions, the issue persists. Further investigation is needed to resolve why th ...

A revolutionary approach - Empowering websites with individual scrolling panels

I have a unique design layout that includes a top navigation, side navigation, and content. Both the side navigation and the content sections are taller than the page. My goal is to eliminate the need for a scrollbar for the entire page, but still mainta ...

Determining if an element contains specific CSS properties and then applying those styles to its parent

I am trying to determine if the <img> element has inline CSS properties defined. If it does, I want to apply those CSS properties to its parent and remove the original CSS declaration. This is my attempt at solving the issue: var $el = $('.arti ...

`Is it possible to modify the background color of InputAdornment in Material-UI TextField?`

For the first 10% of the text field, one background color is used, while for the remaining 90%, another background color is applied. <TextField className={classes.root} type="text" placeholder="username" var ...

Trigger fixed element to appear/disappear when scrolling using JavaScript

I've tried multiple solutions, but I can't seem to get this functionality to work properly on my website. I'm attempting to create a "schedule a demo" button similar to the one on www.bamboohr.com Currently, I have the following html, css, ...

Implementing a Collapse and Expand All feature within an Accordion Component

Hey there! I've been attempting to implement a Collapse All feature on my accordion but am having trouble figuring it out. The resource I've been referencing is this one. I've searched around and noticed that this accordion setup is a bit d ...

How can I center the navbar logo and use it as a toggle for collapsing the menu?

This is a simple example of a navigation bar <nav class="navbar navbar-expand-lg bg-light"> <div class="container-fluid"> <a class="navbar-brand" href="#">Navbar</a> <button class ...

Using CSS Grid to position components in specific regions

Take a look at my HTML code: <div> <div id="navbar" class="box">Navbar</div> <div id="sidenav " class="box">Side Navbar</div> <div id="main " class="box"> ...

HTML table with two rows of cell pairs

Is it possible to achieve the layout shown in this screenshot using an HTML table? I am aware that I can use <div> for this, but I would prefer to maintain the table formatting. https://i.sstatic.net/ESZkn.png ...

What are some strategies for increasing efficiency in my drag and drop process?

Update #2 Wow, transition was stuck at .35s. My CSS just wasn't updating properly :( UPDATE: Anyone know if requestAnimationFrame could help with this? I've got a rotating image reel and I want users to be able to swipe left or right to switch ...

A guide to implementing lazy loading using BXSlider

I have implemented an image gallery using Bxslider, but I am facing an issue with the loading time as there are more than 15 images in each slide. To address this problem, I want to load images one by one when a particular slide appears. I came across an e ...

Adjust the size of the div container while ensuring that all elements are aligned horizontally

My goal is to design a page where all elements remain perfectly aligned, even when the user resizes the window. However, the code I have written does not achieve this. <div style="display:flex; justify-content: left; padding: 3px;"> <div style="m ...

Incorporate concealed image into HTML

When I perform actions with a couple of images, I encounter delays because the browser needs to load the images. For example, if I use $('body').append(''); everything works smoothly without any delays. However, when I try using style= ...

Arrange a collection of thumbnail images within a div so that they wrap onto separate lines

Here is a link to my page: I have NextGen Galleries on the page and I would like them to break lines if needed so they are not all in one line. Instead, I want the galleries to be displayed next to each other. I created an example using Photoshop to show ...

What is the best way to close a dropdown when clicking away from it on the body?

I wish for the dropdown menu to lose its "show" class when clicked anywhere in the body or window, even if it already has the class "dropdown.menu.show". The show class gets removed and added before utilizing the code `(window.onclick = function(event){})` ...

step-by-step guide to disabling grayscale mode automatically

In recent times, a trend has emerged in Thailand where many websites are appearing in grayscale. This is achieved through the use of -webkit-filter: grayscale(100%), filter: grayscale(100%) and similar filters. Although it is possible to revert these webs ...

How to display a three.js scene in the center of a container

I'm having trouble getting my three.js scene to display above some cards and right below my navigation bar. Currently, the scene is rendering under the cards and is not centered. Despite looking at other forum posts for help, I can't seem to figu ...

Customize Google Chrome to display a vibrant splash screen instead of a boring white blank page when

"I've been on the lookout for Chrome apps that can help make my screen darker or inverted to reduce eye strain. While I have found some apps that do the job, there's one thing they don't seem to be able to override - the White Blank page. W ...

Achieving vertical alignment of placeholder in mat-select-field within Angular

I am trying to vertically center a placeholder in a mat-select element. How can I achieve this? It needs to be closer to the bottom of the select input. Here is an image showing my current issue Below are the relevant sections of my code: ...

What is the best way to design an element in HTML/CSS with a curved semicircle border at the top?

I'm looking to design an HTML/CSS element that features a semicircle at the top-middle with a border. Inside this semicircle, I want to place a smaller circle containing a single character (similar to the X in the provided image). Additionally, there ...