Пропустить навигацию
CSS Tip! 🤙 Use custom properties to work out the nested radius of elements for you 😎 .parent {…
0:00 / 0:48

CSS Tip! 🤙 Use custom properties to work out the nested radius of elements for you 😎 .parent {…

jhey ʕ•ᴥ•ʔ

@jh3yy149 тыс. подписчиков

Открыть в X
4 994 отметки «Нравится»СкачатьОригинальный пост

795 893 просмотра

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 👇

10 комментариев

Комментарии из оригинального поста в X (Twitter)

  • Фото профиля jhey ▲🐻🎈

    @jh3yy

    Here's that @CodePen link! 🚀

    70 отметок «Нравится»

  • Фото профиля Aykut

    @aykutkardas

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

    9 отметок «Нравится»

  • Фото профиля jhey ▲🐻🎈

    @jh3yy

    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! 🔥

    4 отметки «Нравится»

  • Фото профиля Jacob Miller

    @pwnies

    @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

    3 отметки «Нравится»

  • Фото профиля Gal Shir

    @galshirart

    @CodePen Smart!

    1 отметка «Нравится»

  • Фото профиля José Breijo

    @josebreijo

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

    1 отметка «Нравится»

  • Фото профиля Eduardo Mexia

    @xtylo

    @CodePen @iCota4G

    1 отметка «Нравится»

  • Фото профиля Khoa • CRO | Landing pages

    @KhoaVariant19

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

    1 отметка «Нравится»

  • Фото профиля Soggy Bread

    @FelixSalyr

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

    1 отметка «Нравится»

  • Фото профиля Anas Bashir

    @an4s911

    @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!!

    1 отметка «Нравится»