CSS Popover + Anchor Positioning is Magical
If you’ve ever needed the positioning of an element to be connected (or anchored) to the position of another element, then you’ll be very excited about anchor positioning in CSS! It is new (as of the time of recording), but thankfully, we have a really good Polyfill, so we don’t have to worry about browser support! 🔗 Links ✅ Code from this video: https://codepen.io/kevinpowell/pen/po... (slightly different, and no polyfill being used here) ✅ Chrome for Developers blog article on anchor positioning: https://developer.chrome.com/blog/anc... ✅ MDN on Anchor Positioning: https://developer.mozilla.org/en-US/d... ✅ Popover Polyfill: https://github.com/oddbird/popover-po... ✅ Anchor positioning polyfill: https://github.com/oddbird/css-anchor... ✅ Browser support for popover: https://caniuse.com/mdn-api_htmleleme... ✅ Browser support for anchor positioning: https://caniuse.com/css-anchor-positi... ✅ I’ve got courses! https://kevinpowell.co/courses ⌚ Timestamps 00:00 - Introduction 00:33 - Turning our element into a popover 02:05 - Only change the display value when the popover is opened 03:25 - A few user agent styles you’ll probably want to overwrite 04:40 - Creating an anchor, and connecting an element to it 06:20 - Using the new anchor() function to position the element where you want 08:20 - Polyfills 10:15 - Change the positioning of the element when it runs out of room with @position-try 13:50 - Semantics 14:50 - Fading the out with allow-discrete 18:20 - Fading the menu in with @starting-style #css -- Come hang out with other dev's in my Discord Community 💬 / discord Keep up to date with everything I'm up to ✉ https://www.kevinpowell.co/newsletter Come hang out with me live every Monday on Twitch! 📺 / kevinpowellcss --- Help support my channel 👨🎓 Get a course: https://www.kevinpowell.co/courses 👕 Buy a shirt: https://teespring.com/stores/making-t... 📽️ Join as a channel member: / @kevinpowell 💖 Support me on Patreon: / kevinpowell or through YT memberships: Join this channel to get access to perks: / @kevinpowell --- My editor: VS Code - https://code.visualstudio.com/ --- I'm on some other places on the internet too! If you'd like a behind the scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter. Bluesky: https://bsky.app/profile/kevinpowell.co Codepen: https://codepen.io/kevinpowell/ Github: https://github.com/kevin-powell --- And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Three CSS patterns I use in every project

Build modals in minutes with the dialog element

10 New CSS and HTML APIs

5 super useful CSS properties that don't get enough attention

When to Use HTML Dialogs vs Popovers

A couple of great anchor positioning use cases

Tailwind's awesome. I'm switching away though.

11 New CSS Features Every Browser Supports in 2025

CSS Anchor Is The Best New CSS Feature Since Flexbox

Top 6 HTML Features You’re Not Using (But Should Be)

Weird and Obscure CSS

Avoid These 5 Awful CSS Mistakes

Make this fun effect that follows your cursor (pure CSS)

5 CSS tips every developer should know

Can We Recreate this Lando Norris text effect?

Naming things just got easier thanks to @scope

How The New POSITIONS Will Work in MODERN CSS

A deceptively complex form / HTML & CSS / Frontend Mentor

The future of CSS layouts: a new unified approach

