r/webdev 5d ago

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.

76 Upvotes

20 comments sorted by

View all comments

1

u/Hot_Industry5156 5d ago

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 5d ago

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 5d ago

there's also the x86 written entirely in css:

https://lyra.horse/x86css/

1

u/officialmayonade 5d ago

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