I got one strange problem which I never got before. Please see this code:
The css:
#btn{
margin-left:150px;
padding:10px;
display:block;
}
#btn a{
padding:5px 20px;
background:green;
color:#FFF;
text-decoration:none;
outline:none;
}
#btn a:hover{
background:#933;
}
#btn a:focus, #btn a:active{
background:#CF0;
color:#000;
}
Here the HTML
<div id="btn">
<a href="#">Click here</a>
</div>
The focus and active css working well in firefox, but not in the chrome and safari.
Edit (8/29/2022)Safari has implemented :focus-visible in version 15.4.
The :focus-visible pseudo-class applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics that the focus should be made evident on the element. (Many browsers show a "focus ring" by default in this case.)
Buttons are not click focusable in Safari (though you can still focus them via keyboard with Option + Tab), as they don't receive focus on click they don't even match :focus , so they never show a focus ring on mouse interactions.
This state is usually indicated using the outline . Adding the :focus pseudo-class to an element will make it show a focus specific styles and disregard browsers heuristics. The :focus-visible , in contrast, applies custom styling only if it would be shown natively.
Yeah seems like little problem with focus in webkit. Not really a bug. Easily fixable in html. Just use tabindex.
<a href="#" class="hide" tabindex="1">[hide]</a>
<a href="#" class="show" tabindex="2">[show]</a>
ta da ...
It's fixable, some additional code needed though...
<div id="btn">
<a href="#" tabindex="1">Click here</a>
</div>
jsfiddle
I know it's ridiculous... You can read more here
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With