Numerous divs featuring hover effects that dynamically change color upon completion of the webkit color transition

I encountered an issue with my CSS file that is separate from the main stylesheet of a webpage. The problem arises when I have three hyperlinks in consecutive order, each enclosed within their respective p tags and divs for specifying webkit transition colors. While the colors work perfectly during the transition phase, once it completes, all three links change to the color specified in the last class of the CSS (gray). Interestingly, upon removing the last class, the final color for all links shifts to the new "last class" color (blue).

This peculiar behavior only occurs after I have visited the links; everything works fine if I clear cookies and refrain from clicking on any links. It seems like there might be an issue related to a:visited, although I believe I have accounted for that in the code.

Here's a snippet of the CSS:

.orangelink a:link:hover,a:hover,a:visited:hover        {
color: #cc7839;
text-decoration:none;
/* font-weight:bold; */
-webkit-transition:color 0.5s ease-in; 
-moz-transition:color 0.5s ease-in;

}

.bluelink   a:link:hover,a:hover,a:visited:hover    {
color: #7290a4;
text-decoration:none;
/* font-weight:bold; */
-webkit-transition:color 0.5s ease-in; 
-moz-transition:color 0.5s ease-in;

}



.graylink   a:link:hover,a:hover,a:visited:hover        {
color:  #b0afaf;
text-decoration:none;
-webkit-transition:color 0.5s ease-in; 
-moz-transition:color 0.5s ease-in;

}  

It appears that there might be a small detail that I am overlooking. Just to clarify, there isn't any interference from the main CSS file, as 'a' is not defined apart from setting the color of inactive hyperlinks.

Answer №1

When declaring your styles, make sure to include the parent class for a:link:hover...

.graylink   a:link:hover,
.graylink   a:hover,
.graylink   a:visited:hover{
    color:  #b0afaf;
    text-decoration:none;
    -webkit-transition:color 0.5s ease-in; 
    -moz-transition:color 0.5s ease-in;
}  

By following this pattern for other colors as well, you will achieve the desired result.

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

Is there a way to align my anchor tag so that my link appears perfectly centered both vertically and horizontally on the page?

Despite my efforts to find a solution, I am stuck with this issue. Here is the code I have been working on: <a href='/Customers' class='centre'>Start</a> I attempted to wrap it in a div tag and also wanted to add a small gr ...

Alert popup onclick feature is malfunctioning

SOLVED: I finally figured out the issue and it is now working perfectly. I had to manually switch to Chrome instead of using the Brackets live viewer. I want an alert box to pop up when the "Home" link is clicked on my website. I tried creating a separate ...

Learn how to trigger an animation when hovering over an element, and how to pause it once the hover is

I am facing an issue with a button that I want to rotate upon mouse hover. The problem is, the rotation works perfectly when the mouse enters, but it continues spinning even after the mouse leaves. Here's the code snippet for better understanding: ...

Tips for creating line breaks in Google Chart tooltips

I'm having trouble breaking a line in the code snippet below. Here is the complete code: <html> <head> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script ...

Troubleshooting issues with hero banner image display in CSS and HTML

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Mountains&l ...

What are the steps to prevent the information in a text box from disappearing after submitting and calculating?

When this code is executed, it retrieves information about the starting and ending addresses and calculates the distance between them. However, a problem arises when the user submits the form - the input fields for entering the addresses are cleared. < ...

Tips for concealing overflowing CSS content

How can I prevent CSS content from overflowing? I am trying to display a price tag in the CSS element, but it is protruding out of my card. .content{ content:''; position: absolute; left: 309px; ...

Utilize CSS to position an image in four various locations on a web page

Expressing this may be a challenge, but I'll give it a shot. Within a div, there is text that can vary in length based on user input. My goal is to have the ability to insert an image in one of several positions, determined by the selection made in a ...

The CrispyError raised an issue because the `as_crispy_field` function was given a field that is either invalid or does not exist

I am currently developing a Django application that includes a contribution form. I have constructed the form using Django models and forms. However, upon attempting to run the application, I encountered the following error message. crispy_forms.exception ...

Issue with initial width calculation of Slick slider

Having issues with implementing the Slick slider. The calculated width of each slide seems to be incorrect due to padding on the right side of the image. <div class="responsive-slick"> <img src="Gallery/large/01.jpeg"> <img src="Gal ...

Movement occurring outside the boundaries of the element

Whenever I hover over the hyperlink, it extends beyond the text of the link. Check out the jsFiddle demonstration: jsFiddle It seems like it is taking the width of the <div>, causing it to be displayed across the entire <div>. Below is the H ...

Apply a translucent background color to an image element using CSS

Is there a way to create an overlay div using my HTML markup without adding any additional code? I want to add a dark overlay with opacity over the image, but I'm limited in what I can use. background: rgba(0, 0, 0, 0.5); Here is the current marku ...

Enhance webpage speed by enabling browser caching for embedded iframe CSS and Javascript files

Imagine having a file named main.html. Inside this file, there's an iframe that points to another file called sub.html. Additionally, there's a button on main.html that, when clicked, refreshes the content of sub.html. This sub.html file relies o ...

I'm facing an issue with the background-image binding in Ionic 3 where it does not seem to work, regardless

I'm encountering a perplexing issue with Ionic 3 (specifically involving template binding, I believe, and styles) that has been perplexing me for the past few days. Despite my efforts, I've been unable to pinpoint a solution or identify the cause ...

Nested div within another div, shifting position relative to scrolling (React)

My goal is to create a unique effect where an object falls from the sky as the user scrolls down the page. The concept involves having the object div remain stationary in the center of its parent container, positioned 50 pixels from the top. However, when ...

Ways to Fix the React Hydration Issue in Next.js

I have been encountering an issue with the error message "Hydration failed because the initial UI does not match what was rendered on the server." I am unsure of what is causing this error and would appreciate any insights or suggestions from others who ma ...

How can we stop every tab pane in (bootstrap five) from sharing the same scroll position? Each tab is currently synchronized with the scroll position of the others

In Bootstrap 5, the scroll position remains the same when switching between tabs in the tab pane. Whether moving from tab #1 to tab #2, both tabs are at the identical scroll position, failing to preserve each tab's specific location. <div class=&qu ...

Craft a backdrop with subtle hints of italics

I am looking to create a unique background for my webpage using HTML and CSS. I want to have repeated italic shades in various shades of blue, red, and white, similar to rectangular shapes. For inspiration, take a look at the design on this website: If n ...

What is causing this Container Div to disrupt my design?

I have a situation where I am attempting to place two elements, a "read more" button and another floating button, inside a container. However, I want both of these elements to align to the left within the container. Strangely, when I run the code, the elem ...

Fade in and out of page or div elements with a simple click

I've been dedicating some time to my recruitment website lately. As a beginner in coding, I'm looking for a script that will automatically fade out the Employment review content when clicking on each employment vacancy div and then fade back in w ...