Anchor positioning + newsletter only bonus lesson


View this email in your browser (or share it with a friend!)

Hello Reader,

Sometimes when I try out a CSS feature to test something out quickly, it does whatever it promised to do, I’m happy, and I move on to other things, storing it away for when I might need it.

Other times, I go down a bit of a rabbit hole, which I did this week when testing something out with anchor positioning.

I wanted to test out if I could create a transition when changing what an element was anchored to… and it turns out that you can’t transition --position-anchor. Or well, you can, but it’s a discrete animation, so it just flips from one to the other.

But, you can transition the top, bottom, left and right values, and that works even if you are switching the position anchor!

It's a bit hard to explain in writing, so I created a short, newsletter-exclusive tutorial!

video preview

Here is the finished codepen from that video is you want to poke around (only works in Chromium browsers and latest release of Safari)

And once I figured that out, I started having a little bit too much fun with it, making this over-the-top navigation (browser support isn’t fantastic, so if that codepen doesn’t work for you, you can see what it would be in this video)

video preview

The more I played with it, the more ways I tried to push what I could do with it, and everything worked in a very intuitive way, which was exciting.

Or well, almost everything.

I did run into a few frustrations, like if the parent element is the named anchor, and is also using position: relative, the element doesn’t see the anchor!

There are a few head-scratchers with some of the edge cases with how anchor positioning works, but thankfully OddBird has a great guide on the issues you might run into and the workarounds.

And, if you’d like to learn more about it and don’t want to wait (I will be putting out more content around it, but it’s likely ~2 months away at the earliest), OddBird also has a great email-based course diving into it. It’s one of the few emails I’m happy to see land in my inbox each week.

🙋‍♂️ What I’ve been up to this week

Breaking through the ShadowDOM with Style Queries

video preview

If you’ve ever created a web component, you might have first thought the shadowDOM was amazing, only to almost immediately be frustrated by some of it’s limitations. Luckily, we have style queries now, and they make working with it a lot easier!

⚡ HTML & CSS Tip of the week

While most people know of :nth-child(), a lot don't know about :nth-last-child(), which can open up some interesting possibilities.

Summer time is here, which means a bit of travelling and a lot more family time than usual, so there won't be any Shorts or podcast episodes for the next 4-6 weeks. They'll each be back in due course though!

📝 Quiz time!

Last week, I caught some people off guard with a logical property, so let’s stick with that theme: Which CSS logical property is equivalent to margin-left in a left-to-right writing mode?

  • margin-block-start
  • margin-block-end
  • margin-inline-start
  • margin-inline-end

As per usual, you'll have to head on over to YouTube to take a stab at the quiz, and once you answer you'll see if you were right or not.

🔗 Other awesome stuff around from the web

🏁

Have a fantastic week!
Kevin


Are you looking to step up your CSS? I've got both free and premium courses to help with that! They cover a range of skill levels too 👇

Beginner friendly (and free)

Conquering Responsive Layout

A free course to help you approach responsive layouts with the right mindset.

Enroll →

Intermediate

CSS Demystified

For those who've been writing CSS for a little bit now, but want to step up their game and start writing CSS with confidence!

Enroll →

Advanced

Beyond CSS

An advanced course that dives into project architecture, theming, design systems, and more.

Enroll →

If you no longer want to get any emails from me, you can unsubscribe or you can edit your preferences if you'd like pick which emails you get from me.
113 Cherry St #92768, Seattle, WA 98104-2205

Hi! I'm Kevin

Weekly newsletter, where I talk about tangentially-related front-end development topics and share what I've been up to in the last week, plus any cool/fun/interesting/useful links I come across as well.

Read more from Hi! I'm Kevin

View this email in your browser (or share it with a friend!) Hello Reader, Next week is the last week of school for my kids… which is insane because how did we manage to get this far into the year already?! It also means that I’ll be doing a little less work than usual, as there’ll be a bit more family time, activities, and travels going on, especially through July for me. I’ll still be putting out this newsletter, and I have a backlog of YouTube videos recorded, so the regular stuff will...

View this email in your browser (or share it with a friend!) Hello Reader, Lots of content this week… meaning I was busier than usual and we’re skipping the general musings for this week! 🙋♂️ What I’ve been up to this week Create this trendy blurry glass effect with CSS I didn’t plan for this to coincide with Apple’s new Liquid Glass UI, but I guess the timing was good! It’s not the exact same thing as what Apple’s Liquid Glass, but with the hot mess it is in terms of accessibility, that...

View this email in your browser (or share it with a friend!) PRE-S: The latest State of CSS survey is now open! I’ll be doing a live stream this upcoming Thursday or Friday, going through it myself, but you might as well jump in first! The more people who take this, the more representative it is, and the browsers use the data from these to know what features need improving and what is missing, so it is worth the time to take! Hello Reader, I’ve been getting a lot of comments lately asking...