Loading video...

Video Failed to Load

Go Home

Must be time for the Q4 nested radius post 📅 Remember, the CSS tip is that you can use custom properties to work out the nested radius of elements for you 😎 .panel { --radius: 28px; --padding: 8px; --nested-radius: calc(var(--radius) - var(--padding); } .content { border-radius: var(--nested-radius); } Here's...

533,066 views • 3 years ago •via X (Twitter)

10 Comments

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈3 years ago

Here's that @CodePen link! 🚀

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈3 years ago

Bunch of people have been quoting my Q3 post on this in response to some of those satirical posts 😅 Figured I might as well roll it back out again 🤙

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈3 years ago

If you have a border present, it's good to account for that too 💯 .panel { --nested-radius: calc( (var(--radius) - var(--padding)) - var(--border) /* Account for the border 🤙 */ ); }

Adam Argyle's profile picture
Adam Argyle3 years ago

also! overflow-clip-margin: content-box; no math, which can be nice

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈3 years ago

This was gonna be the follow-up 🤫😅 Purely revisiting the radius - padding trend 😅

Danny Clayden Chambers's profile picture
Danny Clayden Chambers3 years ago

This post is cutting edge 😄

jhey ▲🐻🎈's profile picture
jhey ▲🐻🎈3 years ago

Haha – I was almost fearful of a bug in Edge being raised there 😅

Dan ⚡️'s profile picture
Dan ⚡️3 years ago

I find this oddly satisfying. should pick up border radius as a hobby 😃

siriwatknp's profile picture
siriwatknp3 years ago

Thanks for the tips @jh3yy. I found an edge case where `padding` > `radius` and got it covered with: --nested-radius: max((var(--radius) - var(--padding), min(var(--padding) / 2, (var(--radius))); I use this trick all over the place for @Joy_UI_

Juri · juri.dev's profile picture
Juri · juri.dev3 years ago

I just saw someone ask for exactly this the other day here

Related Videos