Please check this codepen with a) Firefox and b) Chrome. Proceed as follows:
- Move mouse on link
- Click link and do not move mouse cursor at all afterwards
- Wait until page has reloaded.
If you haven't moved the mouse cursor, it will still be above the link after the page has reloaded.
Firefox will apply the :hover
styles now.
Chrome (Mac OS X) will display the element in it's non-hovered state (which is what I prefer in my scenario).
Anyone here who has an idea which browser does it right, and how to get one browser mimic the other's behaviour?
For my current scenario, I'd like to know how to avoid :hover
being triggered directly after page reload. I'd be quite unhappy if I had to resort to Javascript for that.
For completeness' sake, here's the demo's code:
<a href="https://codepen.io/connexo/pen/pEJbqj" target="_top">This Codepen</a>
a {
color: #333;
background-color: #ddd;
display: inline-block;
line-height: 40px;
padding: 20px;
text-decoration: none;
transition-duration: .4s;
&:before {
content: "non-hovered";
}
&:hover {
background-color: #a00;
color: white;
&:before {
content: "hovered state";
}
}
}
Edit: As one of my colleagues just told me, it seems that Chrome behaves in the described way only on OS X, but not on Windows. Can anybody elaborate on the whole issue?