I use the CSS transition for my hyperlink elements to make their interaction smoother. But I also want immediate feedback when the user is waiting for it. Therefore, I want the new state to appear immediately, but let it disappear when the user leaves.
Here are some CSS I'm using right now:
a
{
display: inline-block;
padding: 20px;
background: #eeeeee;
color: black;
text-decoration: none;
transition: background 1s;
}
a:hover
{
background: #bbbbbb;
transition: background 0s;
}
a:active
{
background: #888888;
transition: background 0s;
}
<a href="javascript:void(0)">Test link</a>
Run codeHide resultAs you can see, color wilting works when you leave an element with the mouse cursor, but not when you enter it.
When you click on a freezing link, the color changes immediately again.
: , , . , :hover , , .
, , .
:
State: normal <----------> hover <----------> active
Transition: yes no yes? no
(currently no)
CSS? , JavaScript, .