Recently, I've come across an issue with styled <a>
and <button>
tags. This problem arises when using display block or inline-block, some padding, and positioning relative to adjust the position on :active.
a { display: inline-block; padding: 3px 6px; background: #aff; }
a:active { position: relative; top: 1px; left: 1px; }
The issue involves a 1 pixel invisible box around the text where clicks are not being registered by the browser or JavaScript, despite animations still occurring. This issue has been observed in browsers like Firefox and Chrome on Windows.
For a live demonstration of this problem, visit:
I have attempted solutions such as using margins instead of position: relative;
and setting .active
with JavaScript instead of utilizing :active
.
To clarify, the deadzone I am referring to is inside the link (the blue box in my example) but outside the bounding box of the text. Check out this image highlighting the area of concern in dark blue: