正在加载视频...

视频加载失败

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...

532,865 次观看 • 2 年前 •via X (Twitter)

10 条评论

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

Here's that @CodePen link! 🚀

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

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 ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

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 的头像
Adam Argyle2 年前

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

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

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

Danny Clayden Chambers 的头像
Danny Clayden Chambers2 年前

This post is cutting edge 😄

jhey ▲🐻🎈 的头像
jhey ▲🐻🎈2 年前

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

Dan ⚡️ 的头像
Dan ⚡️2 年前

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

siriwatknp 的头像
siriwatknp2 年前

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 的头像
Juri · juri.dev2 年前

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

相关视频