正在加载视频...

视频加载失败

CSS Tip! 🤙 Use custom properties to work out the nested radius of elements for you 😎 .parent { --nested-radius: calc(var(--radius) - var(--padding)); } .nested { border-radius: var(--nested-radius); } Couldn't resist making an interactive visual! CodePen.IO link below 👇

795,379 次观看 • 2 年前 •via X (Twitter)

10 条评论

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

Here's that @CodePen link! 🚀

Aykut 的头像
Aykut2 年前

@CodePen I have an interactive article where I explain the logic here. ✨ 👉🏻

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

No SoundCloud 😞 But. If you're a developer who wants to pick up some more design skills, my "soon-to-be wife"(👀) has written a book and it's 45% off 👇 Grab a copy! 🔥

Jacob Miller 的头像
Jacob Miller2 年前

@CodePen From a design standpoint this is a great best practice. From an implementation standpoint, I typically don't like to have dynamic css for static code. Assuming the border radius base value and the padding never change, I'd move this into the preprocessor rather than use a calc

Gal Shir 的头像
Gal Shir2 年前

@CodePen Smart!

José Breijo 的头像
José Breijo2 年前

@CodePen Giving control to the user is fundamental to enhancing the experience to their likeness, great work on building some tooling 🙏👌. Btw I'm curious about your opinion of I made the tooling there with Preact signals 👀.

Eduardo Mexia 的头像
Eduardo Mexia2 年前

@CodePen @iCota4G

Khoa • CRO | Landing pages 的头像
Khoa • CRO | Landing pages2 年前

@KevinJPowell @CodePen So useful! thanks for sharing! =)

Soggy Bread 的头像
Soggy Bread2 年前

@CodePen 🙏 Bless you I’m putting this into practice today as a reusable scss mixin

Anas Bashir 的头像
Anas Bashir2 年前

@CodePen I am right now building a tic tac toe game, and put border radius for a parent and child, and it looked weird, and then I remembered this and searched it up and thank god I found it. Thank you so much!!

相关视频