Generating obscured links that appear when hovered over, with a clear background for the enclosing div

My navigation menu consists of a div element that becomes slightly transparent when hovered over (while all hyperlinks are opaque before the hover). I am trying to achieve the effect where the current hyperlink being hovered returns to full opacity, similar to the navigation on this website:

I need help figuring out how to implement this style in my navigation. Any guidance on how to achieve this would be greatly appreciated.

a:focus,
a:hover {
  color: #333300;
}

a {
  text-decoration: none;
}

.header-inner {
  padding: 20px;
}

#header-nav ul {
  list-style-type: none;
}

#header-nav ul li {
  display: inline-block;
  position: relative;
  zoom: 1;
  -webkit-backface-visibility: hidden;
  vertical-align: middle;
  font-size: 20px;
  margin: 0 auto !important;
}

#header-nav ul li a {
  margin-left: 60px;
  transition: .4s all ease-in;
  font-weight: bold;
  color: #333300;
  padding: 0 10px;
}

#header-nav {
  width: 50%;
  height: 25px;
  margin: 0 auto;
  transition: .2s ease-out;
}

#header-nav:hover {
  opacity: .5;
}

.header-nav-item {
  color: #333300;
}

#header-nav:hover>.header-nav-item {
  opacity: 1;
}
<div class="container-fluid">
  <header class="header header-bottom">
    <div class="header-inner">
      <nav id="header-nav">
        <ul>
          <li><a href="#" class="header-nav-item">item1</a></li>
          <li><a href="#" class="header-nav-item">item2</a></li>
          <li><a href="#" class="header-nav-item">item3</a></li>
          <li><a href="#" class="header-nav-item">item4</a></li>
          <li><a href="#" class="header-nav-item">item5</a></li>
          <li><a href="#" class="header-nav-item">item6</a></li>
        </ul>
      </nav>
    </div>
  </header>
</div>

Answer №1

Let's make a simple modification

#header-nav:hover li:not(:hover){
    opacity: .5;
}

This adjustment ensures that only the non-hovered items will have reduced opacity when the full container is hovered over.

Take a look at this code snippet:

a:focus, a:hover {
    color:#333300;
}

a {
    text-decoration: none;
}

.header-inner {
    padding: 20px;
}

#header-nav ul {
    list-style-type: none;
}

#header-nav ul li {
    display: inline-block;
    position: relative;
    zoom: 1;
    -webkit-backface-visibility: hidden;
    vertical-align: middle;
    font-size: 20px;
    margin: 0 auto !important;
}

#header-nav ul li a {
    margin-left: 60px;
    transition: .4s all ease-in;
    font-weight: bold;
    color: #333300;
    padding: 0 10px;
}

#header-nav {
    width: 50%;
    height: 25px;
    margin: 0 auto;
    transition: .2s ease-out;
}

#header-nav:hover li:not(:hover){
    opacity: .5;
}



.header-nav-item {
    color: #333300;
}

#header-nav:hover > .header-nav-item{
    opacity: 1;
}
<div class="container-fluid">
        <header class="header header-bottom">
            <div class="header-inner">
                <nav id="header-nav">
                    <ul>
                        <li><a href="#" class="header-nav-item">item1</a></li>
                        <li><a href="#" class="header-nav-item">item2</a></li>
                        <li><a href="#" class="header-nav-item">item3</a></li>
                        <li><a href="#" class="header-nav-item">item4</a></li>
                        <li><a href="#" class="header-nav-item">item5</a></li>
                        <li><a href="#" class="header-nav-item">item6</a></li>
                    </ul>
                </nav>
            </div>
        </header>
    </div>

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

Utilize Jquery to hide radio buttons, while allowing users to click on an image to display a larger version

My current HTML structure is restricted to SAAS, so I only have control over jQuery implementation. https://i.stack.imgur.com/OHB9K.jpg I am attempting to achieve a similar layout as shown in the image below. The main issue lies in how to (1) conceal ...

Tips for keeping a label above an input field

Is it possible to add a styled label on top of an input element? I have seen images placed inside input elements for indicating the type of input accepted. For example, in a login form, a user icon represents the username field and a key icon represents th ...

Obtain picture from firebase utilizing react Js

I have attempted multiple methods to download images from Firebase, but the download URL is not functioning as expected. Instead of downloading the image directly, it opens in a new tab. The function used in Firebase: export async function addMedia(locati ...

Vue: How to access Vue instance from a function outside of its scope

In my data object, there is a small section dedicated to creating a navigation menu. This menu contains buttons that should trigger specific functions. I decided to store these functions within the data object for clarity. However, the issue arises when t ...

Error encountered: Circular reference issue was encountered when attempting to retrieve navigator.plugins with the use of Selenium and Python

I'm attempting to access the value of navigator.plugins from a Selenium-driven ChromeDriver initiated google-chrome Browsing Context. Using google-chrome-devtools, I am able to retrieve navigator.userAgent and navigator.plugins as shown below: https ...

Exploring the world of JMeter: capturing sessions with JavaScript and jQuery

I need to capture a user session in order to conduct a performance test. I have been using the JMeter HTTP(S) Test Script Recorder, but unfortunately it is not recognizing javascript and jquery. The error message I'm receiving is: JQuery is not def ...

Return a string to the client from an express post route

I'm attempting to return a dynamically generated string back to the client from an Express post route. Within the backend, I've set up a post route: router.post('/', async (req, res) => { try { // Here, I perform computations on ...

In Node.js, use the `[]` operator to select elements from an array of strings without including

In my situation, I am working with an array of strings which can sometimes be an array containing only one string. The issue is that when this happens, using array[0] to retrieve the value does not return the entire string but rather just the first charact ...

Designing a dropdown menu with sub-menus that appear when hovered over

In my quest to design CSS that will dynamically display links in left-to-right divs, I am seeking a way for sub-menus to appear below the menu being rolled over. The challenge lies in the fact that these menus will be loaded from a WordPress database, mean ...

Top method for patiently awaiting the completion of the .forEach() function

There are times when I find myself waiting for a .forEach() method to complete, especially in functions involving loaders. My current approach involves using the following code: $q.when(array.forEach(function(item){ //perform iteration })).then(func ...

Is it appropriate to include this jquery code within an angular controller?

When creating a list of rows in an HTML table using ng-repeat, I encountered an issue with styling radio buttons using jQuery. The code snippet below shows the jQuery script used to apply the style: <script> $(document).ready(function () { $('. ...

Issues with color scheme in Angular Material 18

While using (ng generate @angular/material:my--own-theme), I came across some code in own-theme.scss. Surprisingly, this code works for the palette included in Angular Material, but I prefer to use my own theme. Here's what was generated and what I di ...

Unable to send an HTTP request using intent

I'm currently facing an issue where an intent triggers an HTTP request, but I keep encountering errors. Whenever the intent is triggered, the following code is executed: const https = require('https'); https.get('*************' ...

Creating a subtle vanishing popup dialog using only CSS (no reliance on jQuery)

Is there a way to add a fade effect to my simple pop-up image using CSS? I've tried various transition properties, but nothing seems to work. Any suggestions would be appreciated. Thanks! ...

arrangement of cart in Shopify's mobile interface

Having trouble aligning the basket on the top row of my website when viewed on mobile. The position seems to randomly switch between top and bottom, and I can't figure out where in the code to make adjustments. Any advice would be greatly appreciated ...

New Angular Datatables used to create a revitalizing table

In my project, I am utilizing the Angular Datatables library. The data is fetched from a URL that returns a JSON object, which is then stored in an array and used to populate a table. appenditems(){ this.items = []; this.items2 = []; this.items ...

Find the value of a JavaScript string variable using an alternative name

My latest JavaScript function is designed to fetch JSON data from either a server or local files on any browser. This piece of code processes JSON from two sources: an XMLHttpRequest response, or a variable imported via script. In the case of the latter, ...

Deactivating AngularJS debug information in a gulp / typescript production compilation

What is the most effective approach to disabling debug data in a gulp production build? The recommended method for disabling debug data is: myApp.config(['$compileProvider', function ($compileProvider) { $compileProvider.debugInfoEnabled(false ...

AngularJS and the Angular UI Router were combined for the first time in

Hey everyone, I could really use some help as I'm just diving into the world of AngularJS. Can anyone guide me on how to tackle these pesky errors? Error: app.js:6 > Uncaught ReferenceError: angular is not defined Error: angular.min.js:6 > Unc ...

Troubleshooting Vue 3: Dealing with Synchronization Issues Between Keyboard Input and

I am currently working on a Vue 3 autocomplete component and I've come across a strange issue that I can't quite figure out. The component emits two events: "update:search" to update the search variable in the parent component, and "change" whic ...