Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS a:hover keep original color

Tags:

css

Is it possible to keep the color on a link with a class while other links do change.

For example I have a theme but i want it to support different colors set by the user.

Most links change color on :hover but some must stay the same color.

#red is generated by the theme. I want to 'inherit' the a.someclass:link color in the a.someclass:hover

example:

a:link
{
  color: #red;
}
a:hover {
  color: #black;
}

The above part is generated which I cannot alter.

As suggested in answers and comments below I need to build this with jQuery

sure I can copy #red to the a.someclass:hover {} but then i have to hardcode the color and since the user should be able to change the color that is not an option.

I need something to overide the a:hover { color } if the class is someclass

like image 489
FLY Avatar asked Dec 30 '11 15:12

FLY


People also ask

How do you make something change color when you hover over it CSS?

Changing link color on hover using CSS To change the color of your link on hover, use the :hover pseudo property on the link's class and give it a different color.

How do you change the color of button on hovering?

To change the background color of the button, use the CSS background-color property and give it a value of a color of your taste. In the . button selector, you use background-color:#0a0a23; to change the background color of the button.

Is hover a CSS selector?

The :hover selector is used to select elements when you mouse over them. Tip: The :hover selector can be used on all elements, not only on links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :active selector to style the active link.


1 Answers

You can make use of currentColor

a.no-color-change:hover {
  color: currentColor;
}
like image 134
zurfyx Avatar answered Sep 24 '22 14:09

zurfyx