Edit #3 - Question rewritten
Issue: border width of anchor tags unexpectedly increase on mouseover when a:hover
css selector is used.
Question: Is this a Firefox bug or a CSS behavior I am unaware of?
- Requires Firefox 57.0.0 - 57.0.2
- Adjust browser page size to 2,000+ pixels.
- Run code snippet.
- Increase and decrease the width of the browser page using the two-headed horizontal arrow cursor.
- Hover your mouse over the link and you will see the border width increase from
1px
to1.11667px
.
a:hover {}
a {
border: 1px solid #000;
}
<a href="#">Link</a>
Original Question
This does not happen on Chrome or Firefox 50.0.0 and 56.0.2.
To test this you'll need:
- Firefox 57.0.0 - 57.0.2 (the latest version on Dec 13th, 2017).
- A large screen around 2,000 pixels.
If your screen isn't that big, you can press cmd -
to zoom out. If you're not sure how big your screen is, you can use Firefox's page rulers.
Issue
I've created a js fiddle. Move the vertical column separating the JavaScript and rendered output as far to left as it goes. Make the browser window as wide as you can, and zoom out if you need to. Click Run
. Move your mouse over the yellow boxes and take note that nothing happens.
Now, resize the width of the browser window, making it smaller and larger. Hover over the boxes again and you'll see they start moving. For some reason, Firefox is changing the border width from 1px
to 1.66667px
.
I've found the a:hover
CSS selector is causing this issue. If you read the comments in the js fiddle, even just putting an empty a:hover {}
in the CSS will cause the issue. I cannot remove the a:hover
line from the CSS on our website, unfortunately. I realize I can use outlines instead of borders to fix the rendering issue.
My question is whether this is a Firefox bug or something I don't know about the a:hover
selector and borders?
Edit: The desired behavior is for the borders to not change their width.
Edit #2: A simpler js fiddle.