I want to make a button that displays a background color when hovering and a button color without a background color when the button is down. Here is my current code:
.windowButton:hover {
background-color:#1a82b8;
}
.windowButton:active #windowClose polygon {
fill:#1a82b8;
}
The problem with the above code is that it turns the icon a color when :active
but doesn't remove the background color set by :hover
. How do I remove the background color?
You have to set a new background color on
:hover
statePseudo states inherit values. For consistency purposes, it is best to only declare the styles which you are changing in your pseudo state rules.
Note:
:hover
MUST come after:link
and:visited
(if they are present) in the CSS definition, in order to be effective!How about this?
I would guess, its cause on the first property you are using background-color and the second fill.
jsFiddle working example (1)