Did you know it was possible to mimic the double-click behaviour in CSS? The only ingredients you need are some
<a>
tags that block the first click.
I've used
<a>
tags with a
tabindex
because these where the only elements that are stylable in all browsers. Thanks
Chris Rebert
for the reseach about
click and focus behavior across browsers & OSes
.
The
href
is removed to prevent navigation or page jumps (with #-links).
As Don Caviness pointed out , Edge seem to behave a bit strange. It only works if you click - move the cursor a bit - and click again.
If you want to find out how it works, you can set
$debug: true;
to enable debug mode.
WARNING : this is just a demostration to show it's possible to use CSS for double-clicks. This technique has some accessibility issues ( see this tweet ). I woudn't recommend to use this. If you do want to use double-click, use javascript .
This link to google can only be opened by double clicking it.
Double-click to play or pause the video.
Thanks Amine Atallah for providing this hosted video.
Double-click to play or pause the video. I've disabled the fullscreen mode, but if you enable this, the video will open fullscreen when you doubleclick it. Add the
allowfullscreen
attribute in this codepen to see this in action.
This example may look very familiar if you've seen my pen with
stuff you can do with CSS pointer events
, but this example doesn't use the
pointer-events
property but the
:focus-within
pseudo class. Not supported in IE & Edge at this moment (
view supported browsers
).
This text changes color if the button in card 1 is double-clicked.
xoxo,
@Martijn_Cuppens
PS. make sure to check out RFS to control your responsive font sizes.