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!

For September, each quiz this month will cover a specific layout feature, and we’re kicking things off with a question on Flexbox:

When using the flex: 1 shorthand property on flex items, what is the computed value of the flex-basis?

  1. 0%
  2. auto
  3. 100%
  4. min-content

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, With summer winding down, I'm winding my own things back up a bit, with this newsletter returning to having a bit of a random ramble at the start, and most of the content I put out on a regular basis back up and running as well. The crazy thing with the summer winding down is that it once again reinforces how fast time is flying by. Every time I blink, it feels like 3 months have passed. And speaking of time flying,...

View this email in your browser (or share it with a friend!) Hello Reader, This edition of the newsletter is the last “summer break” edition. We’ll be back to the full one starting next week 🙂. 🙋♂️ What I’ve been up to this week Select a specific row in a grid, even when using auto-fit or auto-fill A fun look at how we can select a specific row when using grid’s auto-fit feature, including an example by Temani Afif, who looks at how we can do this with a lot less code in the near future. When...

View this email in your browser (or share it with a friend!) Hello Reader, The shorter summer version is still in effect, but I had several DMs and emails this week asking me about my overall approach to writing CSS, and I wanted to let you know that I do have a Frontend Mentor course where I cover exactly that. In the course, we build out a project based on a Figma design, starting from scratch. Throughout, I make a point of emphasizing my thought process on the decisions I’m making along...