Jump to content

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

--

Come hang out with other dev's in my Discord Community 💬  discord_1x.png / 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! 📺  twitch_1x.png / 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:   yt_favicon_ringo2.png / @kevinpowell  
💖 Support me on Patreon:  patreon_1x_v2.png / kevinpowell   or through YT memberships: Join this channel to get access to perks:   yt_favicon_ringo2.png / @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!

Added By 💫 Jimi Wikman

Submitted:

User Feedback

Recommended Comments

There are no comments to display.

Create an account or sign in to comment