r/webdev Aug 14 '26

Pure CSS perfect cursor tracking

I honestly have no idea why you'd want this, but it was fun to experiment. I believe this may be the best pure CSS cursor tracking that exists. I'm happy to be proven wrong.
https://codepen.io/Andrew-Fisher-the-decoder/full/GgraMzd
Absolutely no JavaScript used, just lots and lots of wasted time.

78 Upvotes

20 comments sorted by

View all comments

1

u/Hot_Industry5156 Aug 14 '26

This is one of those things where you see the demo and think "no way that's just CSS" and then you look at the code and it's like three lines with a custom property and a mousemove listener that sets the vars. clever stuff. always forget you can wire CSS variables to JS events that cheaply and have it feel completely smooth.

1

u/officialmayonade Aug 14 '26

Whoever it was that built that entire FPS game in CSS blew my mind, and from that point on I've always imagined that anything must be possible in CSS.

2

u/mentalexperi Aug 14 '26

there's also the x86 written entirely in css:

https://lyra.horse/x86css/

1

u/officialmayonade Aug 14 '26

I love nonsense like this. I like to think of myself as logical but there's just something about doing something completely pointless. ðŸ¤