跳过导航
CSS-only magnetic link effect 🤯
0:00 / 0:22

CSS-only magnetic link effect 🤯

jhey ʕ•ᴥ•ʔ

@jh3yy15万 位关注者

在 X 上查看
4,248 个赞下载原帖

234,760 次观看

CSS-only magnetic link effect 🤯 li:has(a:is(:hover, :focus-visible)) {anchor-name: --a; } ul::before { left: anchor(--a left); width: anchor-size(--a width); } using CSS anchor positioning, declare an anchor on hover for the indicator 🚀

9 条评论

评论来自 X (Twitter) 上的原帖

  • jhey ▲🐻🎈 的头像

    @jh3yy

    here's the @CodePen for this one works in all browsers ✅ where anchoring isn't supported, use :has() with some custom properties on :hover/:focus-visible instead of getting the bounding client rect on every hover, etc. ✅

    61 个赞

  • jhey ▲🐻🎈 的头像

    @jh3yy

    "bUT gpT CaN dO iT if I ASk iT" the issue is, you didn't know what to ask it and it didn't know how to come up with an efficient solution (kinda fed up with some of the reply guys on this platform. you jus get muted or blocked now. don't owe you a thing)

    78 个赞

  • Nicholas Arce 的头像

    @nickarceco

    You make me feel like I know nothing about CSS. I love it.

    13 个赞

  • Mathew Dony 的头像

    @mdmathewdc

    Don't give us the code, someone might accidentally use it

    13 个赞

  • jhey ▲🐻🎈 的头像

    @jh3yy

    👏🏆

    3 个赞

  • Fred Wanders 的头像

    @BrightPixels

    Sorry maybe i m missing something. Where is the magnetic effect

    4 个赞

  • Simon 的头像

    @SimonBitwise

    Its great for tooltips, custom menu dropdowns and select dropdowns when mixed with the popover api 👌🔥

    3 个赞

  • jhey ▲🐻🎈 的头像

    @jh3yy

    yep, it's capable of a lot more too though done a lot of demos and talks around these APIs, they were my job at one point 🚀 (my name is on the spec 😉)

    51 个赞

  • jhey ▲🐻🎈 的头像

    @jh3yy

    for this purpose, it's literally a handful of JavaScript lines to polyfill

    1 个赞