-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Which technique for setting box-sizing: border-box
?
#4
Comments
I'm completely naïve here, but I found the CSS Tricks article and comments convincing. |
I have always used the But recently I needed (for the first time ever) to override the box-sizing for a specific element and realized that all children were affected too. Not what I wanted. I just wanted to change one specific element. After that, I edited my reset file to use The reason many people suggest the inherit version is for components/plugins. But I think it's up to the component author to set the correct box-sizing if it's important for the styling of the component. The end user shouldn't have to deal with that setting for embedded components. So I vote for the one-liner. |
I agree deeply with what @olach just said. I'm going to change it to |
…site author over a componant library author #4 (comment)
I'm reopening this with a question. Should we add the *, *::before, *::after {
box-sizing: border-box;
} |
@olach it looks like it if this still holds true: http://disq.us/p/egkdth *, ::before, ::after {
box-sizing: border-box;
} |
I’m the fellow responsible for the However, if I understand the goal of css-remedy, it is to style “how it should have worked to begin with”. For this same reason, I did the same way as Jen here. @hacknug, @olach, the my research I had done seemed to indicate we had to reset ::before and ::after separately. I’m getting some PRs together, but it’s not a race so nobody wait on me if someone else wants to fix it. |
@olach intended to reopened this... cool. Reopened. We can always change it back. But I think this is the right way to go (in the midst of my busy week, no time for me to think deep), so I merged it. Let the discussion continue... I'm especially curious what @fantasai or @dbaron has to say. Or maybe @dholbert? (For quick reference, we've now got:
|
Closing this out. If someone wants to propose further changes, they can open a new issue/pr with a specific proposal. |
@olach ** I think this is a pretty rare case. And for some small and simple projects, the old trick with |
@RinatValiullov This was a long time ago, so I don't have all the details. But if I recall correctly, I had a clickable element where I needed a specific width/height in pixels for the visual parts of the element. But the clickable area needed to expand outside the element. I solved this by adding padding and/or a transparent border to the clickable element. Since the visible content needed specific dimensions, I had to change the With this change, all children to the element where also affected by this box-sizing change, and that created some layout issues with the children. That's why I changed the reset in my project to use Some people would say that this goes against the nature of CSS, where all properties are inherited. But this is a misunderstanding. Not all properties do inherit. I.e. properties like widths, margins, padding, and borders do not inherit (source). Also of note; according to this PR in the Tailwind repo. The approach with inherited box-sizing doesn't take into account elements dependent on the shadow-dom. |
We could
or we could
which is what several people believe is best. See:
https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/
https://www.paulirish.com/2012/box-sizing-border-box-ftw/
Those articles reflect an agreement that by setting it to inherit on most elements, you can drop in a component that has
box-sizing: content-box
and everything inside that component will also be content-box.@fantasai countered:
Personally I prefer the one line version. Always have. But...
The text was updated successfully, but these errors were encountered: