<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns" -->

---
title: I wish this had always been so easy | daily.dev
description: A hands-on walkthrough demonstrates building a sliding hover/focus indicator effect for navigation links using modern CSS anchor positioning combined with...
canonical: https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: I wish this had always been so easy | daily.dev
og:description: A hands-on walkthrough demonstrates building a sliding hover/focus indicator effect for navigation links using modern CSS anchor positioning combined with...
og:url: https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns
og:image: https://api.daily.dev/og/posts/ZE6vF2pnS.png
og:image:alt: I wish this had always been so easy
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# I wish this had always been so easy

**[Kevin Powell](https://daily.dev/sources/kevinpowell)** · 2 min read · 14 upvotes · 1 comments

## Summary

A hands-on walkthrough demonstrates building a sliding hover/focus indicator effect for navigation links using modern CSS anchor positioning combined with pseudo-elements. The demo covers creating anchor names, linking them to absolutely positioned pseudo-elements, using inset properties with calc() for fine-tuned placement, and adding transitions with custom easing for a bouncy sliding underline effect that follows the hovered or focused nav item.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=PBFooCG3ClY>

## Questions this post answers

### How do I make a nav hover indicator follow the hovered link using CSS anchor positioning?

Give the pseudo elements the same anchor name as the nav items (via anchor-name and position-anchor), since elements always track the last anchor name found in the DOM. Set position: absolute with inset values referencing anchor(top), anchor(bottom), etc., add a transition on the inset properties, and use calc() to fine-tune offsets like an underline that follows the active link.

_See how daily.dev surfaces practical CSS techniques like anchor positioning as they emerge._

### Why isn't my CSS anchor positioning working when I add position: relative to the anchor element?

Adding position: relative to the anchor element can break anchor positioning and cause visual issues. Instead, only the anchored (positioned) element needs position: absolute along with position-anchor referencing the anchor name; the anchor element itself does not need an explicit relative position set.

_Developers debugging layout quirks like this often track CSS platform updates on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@cale** · 0 upvotes

> ![GIF](https://static.klipy.com/ii/40242aa776a8322b6e7934df737fa2a6/da/91/GQE2q2Hb.gif)

## Similar posts on daily.dev

- [The Lazy Tooltip Follower](https://daily.dev/posts/the-lazy-tooltip-follower-7xgufev83) · CSS Tip · 1 upvotes · 0 comments
- [Lessons Learned from Failed Demos: Pure CSS Nav Thumb Flip on Scroll – Frontend Masters Blog](https://daily.dev/posts/lessons-learned-from-failed-demos-pure-css-nav-thumb-flip-on-scroll-frontend-masters-blog-koacpdwqj) · Frontend Masters · 4 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"I wish this had always been so easy","url":"https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns"},"datePublished":"2026-08-27T13:20:33.822Z","dateModified":"2026-09-14T09:22:26.088Z","description":"A hands-on walkthrough demonstrates building a sliding hover/focus indicator effect for navigation links using modern CSS anchor positioning combined with...","image":"https://i.ytimg.com/vi/PBFooCG3ClY/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/PBFooCG3ClY/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Kevin Powell","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Kevin Powell","logo":"https://media.daily.dev/image/upload/s--XK5Rf0kM--/f_auto/v1717745137/logos/kevinpowell","url":"https://daily.dev/sources/kevinpowell"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"webdev,css","timeRequired":"PT2M","video":{"@type":"VideoObject","name":"I wish this had always been so easy","description":"A hands-on walkthrough demonstrates building a sliding hover/focus indicator effect for navigation links using modern CSS anchor positioning combined with...","thumbnailUrl":"https://i.ytimg.com/vi/PBFooCG3ClY/sddefault.jpg","uploadDate":"2026-08-27T13:20:33.822Z","duration":"PT2M","url":"https://api.daily.dev/r/ZE6vF2pnS","embedUrl":"https://www.youtube.com/embed/PBFooCG3ClY"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Kevin Powell","item":"https://daily.dev/sources/kevinpowell"},{"@type":"ListItem","position":3,"name":"I wish this had always been so easy"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns","comment":[{"@type":"Comment","text":"","datePublished":"2026-08-29T10:50:34.877Z","url":"https://daily.dev/posts/ZE6vF2pnS#c-e4FZMYeSl","author":{"@type":"Person","name":"Cale","url":"https://daily.dev/cale","image":"https://avatars.githubusercontent.com/u/211212128?v=4"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/i-wish-this-had-always-been-so-easy-ze6vf2pns#faq","mainEntity":[{"@type":"Question","name":"How do I make a nav hover indicator follow the hovered link using CSS anchor positioning?","acceptedAnswer":{"@type":"Answer","text":"Give the pseudo elements the same anchor name as the nav items (via anchor-name and position-anchor), since elements always track the last anchor name found in the DOM. Set position: absolute with inset values referencing anchor(top), anchor(bottom), etc., add a transition on the inset properties, and use calc() to fine-tune offsets like an underline that follows the active link. See how daily.dev surfaces practical CSS techniques like anchor positioning as they emerge."}},{"@type":"Question","name":"Why isn't my CSS anchor positioning working when I add position: relative to the anchor element?","acceptedAnswer":{"@type":"Answer","text":"Adding position: relative to the anchor element can break anchor positioning and cause visual issues. Instead, only the anchored (positioned) element needs position: absolute along with position-anchor referencing the anchor name; the anchor element itself does not need an explicit relative position set. Developers debugging layout quirks like this often track CSS platform updates on daily.dev."}}]}
```

