CSS: Various elements share a common transition effect, yet they do not fade in or out in a uniform manner

In the process of creating a dropdown menu that transitions with a fade in and fade out effect upon hover, I noticed an interesting anomaly. While all elements share the same transition behavior, there is a noticeable difference in appearance when hovering over the first tab which remains visible. This slight variation between the two elements becomes apparent upon close inspection.

Check out the JSFiddle demo for reference: https://jsfiddle.net/a9b83786/

Snippet of HTML code:

    <div class="nav">
    <!--.xX~Dropdown~Xx.-->
    <div class="navChild navDropdown">
        <!--Dropdown parent-->
        <div class="navTab navTabDropdownParent">
            Units
        </div>
        <!--Dropdown item-->
        <a href="#" class="navTab navTabDropdownItem">
            Length [M]
        </a>
    </div>

CSS styling:

  :root{
  /*Colors*/
  --Normal-Color: #24AAB8;
  --Hover-Color: #26C2A5;
  --Active-Color: #26C24D;

  /*Lengths*/
  --Nav-Height: 60px;

  /*Multiplier*/
  --NavTab-Width-Multiplier: 2;
}
/*Navigation Tabs*/
/*Nav tabs in general*/
.navChild {
  display: inline-block;
  float: left;
  position: relative;
  z-index: 1;
}
.navDropdown:hover .navTabDropdownParent {
  background-color: var(--Normal-Color)
}
.navDropdown:hover .navTabDropdownItem {
  opacity: 1;
}
.navDropdown {
  height: var(--Nav-Height);
}
.navDropdown:hover {
  height: auto;
}



/* MAIN TRANSITION CODE */
.navTab {
  height: var(--Nav-Height);
  width: calc(var(--NavTab-Width-Multiplier) * var(--Nav-Height));
  display: block;
  text-align: center;
  line-height: var(--Nav-Height);
  text-decoration: none;
  color: black;
  transition: all 0.2s linear; /* First transition */
}
.navChild:hover .navTab {
  visibility: visible;
  transition: all 0.2s linear; /* Second transition */
}





/*Buttons*/
.navTabButton:hover {
  background-color: var(--Hover-Color);
}
.navTabButton:active {
  background-color: var(--Active-Color);
}
/*Dropdown*/
.navTabDropdownItem:hover {
  background-color: var(--Hover-Color);
}
.navTabDropdownItem:active {
  background-color: var(--Active-Color);
}
.navTabDropdownItem{
  visibility: hidden;
  opacity: 0;
  background-color: var(--Normal-Color);
}

(For any recent changes, please refer to the JSFiddle link provided)

Answer №1

In certain browsers like Firefox, the appearance is satisfactory. As per information found at this source, transitions involving background color and opacity should yield consistent interpolated values in your scenario. It seems to be a glitch. A quick fix would involve substituting opacity adjustments with alterations to background color and text color: https://jsfiddle.net/hcphs3ey/.

.navTabDropdownItem{
   visibility: hidden;
   color:transparent;
   background-color: white;
}
.navDropdown:hover .navTabDropdownItem {
   visibility: visible;
   background-color: var(--Normal-Color);
   color:black;
}

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

Using jQuery to make an Ajax post request that will load the current page with additional form data appended to the

Below is the HTML code for my registration form: <form id="registerForm"> <input type="text" pattern="[A-Za-z]{1,20}" placeholder="First Name" name="guestFName" title="Up to 20 alphabetical characters" required> <inp ...

What is the best way to implement left padding in Bootstrap 5?

When transitioning from bootstrap4 to bootstrap5, we encountered an issue where the pl-5 class for left padding was no longer working properly. <div class="col-md-6 col-9 p-3 pl-5"> in bootstrap5 this code is not functional ...

Attempting to connect a dynamic drop-down menu in PHP

I am attempting to establish a connection between a populated drop-down list and a form on another page based on the selected AddressID. The dropdown menu currently displays the addressID's of 6 individuals from my database. When a user chooses an Add ...

Guide on how to refresh the page following a post

Currently in the process of building a form within OctoberCMS that triggers a PHP code block. HTML/Twig: {{ form_open({ request: 'onHandleForm' }) }} Please input a string: <input type="text" name="value"/> <input type="submit" ...

Is there a way to position text to the right of an image?

Looking for some help with aligning text to the right of an image within a hyperlink. I want the hyperlink to fill the rectangle and achieve a specific layout similar to attachment1, but currently getting something different like attachment2. If anyone ha ...

How to access a variable from within a Phonegap DB function and return it outside of the

I'm struggling with a phonegap db JavaScript script that isn't returning the final string variable "feeds" outside the function. It's currently showing as "undefined". I need help making the necessary changes to properly return the "feeds" v ...

Is there a way to control the quantity of items that can be dragged to the drop area with dragula?

I'm struggling with a drag-and-drop issue that involves limiting the number of elements in a drop-area to two. I am using the dragula library for this task: If there are fewer than two elements in the drop-area, allow adding a new element from the dr ...

Mysterious JQuery attribute

I've come across a piece of code that utilizes an unfamiliar selector that I can't seem to figure out: $("div[tag=" + someVariable + "]").css("display", "block"); From what I gather, the selector is searching for a div element with an attribute ...

How can I create a single-page application that adjusts to different screen sizes effortlessly?

I am working on developing a single-page application that fits within one screen with the following structure: There is a fixed header that includes: Two columns (1/3 for left, 2/3 for right) : a logo on the left a breadcrumb on the right. The ...

Footer alignment issue when using react-full-page is causing it to not lineup at the bottom of the page

Currently, I have integrated the react-full-page package into my project. However, after adding the Footer to the routes, I noticed that the footer is only visible in the second section of the page and does not appear at the bottom as expected. If you wan ...

Excessive vertical space is utilized by the vertical images in the CSS grid image gallery

My responsive CSS grid gallery is experiencing issues with vertical images disrupting the layout, as they appear at full size instead of remaining square like the others. How can I fix this problem? Thank you! Below is the code snippet: <div id=" ...

Unable to locate template or render function for Vue Draggable Next component

Looking to incorporate Vue Draggable Next into a Vue 3 example page but encountering some challenges. I've attempted to follow the instructions in the repository. However, I ran into issues when importing the Vue Draggable Next component and had to re ...

Set the position to fixed so it doesn't scroll

Is there a way to create a fixed position div that remains in place when the user scrolls, similar to the effect shown in this example image? Position Absolute: https://i.sstatic.net/4RAcc.png Position Fixed (desired effect): https://i.sstatic.net/3DIna. ...

Looking to attach the "addEventListener" method to multiple elements that share the same class?

I'm trying to use an event listener in JS to handle the logic in the "onClick" function, but it's only executing once. I've applied the same class to all four buttons, so I'm not sure why it's only working for the first one. HTML: ...

CSS Dropdown Menu Malfunctioning

I recently created a navigation bar using some online tutorials, and everything seems to be working fine except for the drop-down menu. I've been struggling with it for hours and can't seem to find a solution. Any help would be greatly appreciate ...

PHP implementation of a webpage supporting multiple languages

I encountered an issue while creating a multi-lingual page successfully. I utilized CssFlipper to generate the RTL Bootstrap file and everything was functioning perfectly, except for the fact that when I switch the language to Arabic, the slider on the pag ...

In what way do Tumblr and Google+ creatively arrange images like a jigsaw puzzle?

I'm interested in creating a unique gallery of images and I'm curious about how to stack them similar to Google and Tumblr. What I mean is, on an archive page of Tumblr, the images are stacked in columns like this: However, I also want the imag ...

Expanding and collapsing multiple rows within a Bootstrap grid

Seeking advice on Bootstrap and its implementation of columns and rows. Currently facing a cascading effect where I have managers, followed by employees, and then employee family members. The challenge lies in my limited understanding of how Bootstrap uti ...

Exploring the potential of HTML5 canvas for speedy pixel manipulation

Is there a method to interact with canvas pixels in real-time without using getImageData or createImageData due to their slow performance? ...

What is the best way to insert hyperlinks within every cell of a table using Angular?

I am currently working on a table created with ng-repeat in Angular. The cells are populated by variables in the scope. <tbody> <tr ng-repeat="item in items" myDirective> <td>{{item.title}}</td> <td>{{item.field}}&l ...