I have a button which I am styling in css. I have a hover effect on the button , it works well. However if I click the button and move the cursor away and then back again, the hover effect is lost. How can I fix this in css?
Asked
Active
Viewed 459 times
0
-
Check out the answer to this question: https://stackoverflow.com/questions/13630229/can-i-have-an-onclick-effect-in-css – JimA Sep 15 '21 at 10:23
-
Can you provide us that part of your code? – Castle Sep 15 '21 at 10:33
-
Please provide enough code so others can better understand or reproduce the problem. – Community Sep 21 '21 at 19:11
1 Answers
0
If I understand correctly you could do the same thing by moving your transitions to the link rather than the hover state:
ul li a {
color:#999;
transition: color 0.5s linear; /* vendorless fallback */
-o-transition: color 0.5s linear; /* opera */
-ms-transition: color 0.5s linear; /* IE 10 */
-moz-transition: color 0.5s linear; /* Firefox */
-webkit-transition: color 0.5s linear; /*safari and chrome */
}
ul li a:hover {
color:black;
cursor: pointer;
}

Mohammad Mohammadi
- 11
- 2