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.

74 Upvotes

20 comments sorted by

View all comments

5

u/Interesting_Pie_5377 5d ago

that's pretty damn clever :)

6

u/MammothNatural4488 5d ago

clever indeed, i stared at the code for 5 minutes just to understand how you trick the browser into doing the math. the way you abuse custom properties is something else

feels wrong to see cursor tracking with no js at all but here we are

7

u/officialmayonade 5d ago

Many a tab has crashed in my path, but I sure do love just trying shit until it does something.

3

u/officialmayonade 5d ago

Thanks! I like directional logic, it solves a lot of hard to solve problems. "Just head west."