For years, whenever you needed a tooltip or dropdown that dynamically stays attached to a button and flips when hitting the screen edge, you reached for getBoundingClientRect() , scroll listeners, or libraries like Popper.js / Floating UI.
With CSS Anchor Positioning (Chrome/Edge 125+, Safari 26+), this entire problem is solved in pure CSS.
The Mental Model: Boat & Dock
Think of the button as a Dock and the floating tooltip as a Boat :
anchor-name: --dock-btn; (assigns an anchor identifier to the target)
position-anchor: --dock-btn; (tethers the floating element)
top: anchor(bottom); (positions it relative to the dock edges)
position-try-fallbacks: flip-block, flip-inline; (the browser automatically calculates viewport collisions and flips the element to open space!)
4 Real UI Patterns You Can Build Without JavaScript:
Self-Centered Tooltips across separate DOM containers : Using justify-self: anchor-center .
Collision Auto-Flipping : Using @position-try or keyword presets like flip-block…