-
-
Notifications
You must be signed in to change notification settings - Fork 78.8k
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
Move away from * { box-sizing: border-box } to play nice with 3rd party scripts #12351
Comments
We won't be changing it. |
@mdo No explanation? I think this is a very legitimate complaint and deserves more than a quick "won't fix-closed". |
Because |
Sorry for the brevity, folks. Here's a better explanation.
Hope that helps. I'm not in front of my computer right now, so I'm doing this from my iPhone in a Starbucks. I'll check back in on this as any further comments come in. Apologies again for the asshole-ish brevity. Not my intention to crap on your heart and make folks regret using open source. <3<3<3 |
@mdo If this were to be implemented, I would prefer a build option for no-conflict. Just spitballing, but by doing a no-conflict build it would produce output that would remove any global normalize rule sets and merge global rule sets into the related bootstrap rule sets. To add more complexity, it would be nice if bootstrap specific selectors could be prefixed. This would avoid conflicting with existing legacy selectors. This can already be done by using https://github.com/faucamp/bootstrap_namespace_prefixer, but I feel there is a better way of manipulating the selectors other than using regex. This would also introduce a number of selectors that would have to be specified in the class list for the element. For example, Yes, there are plenty of negatives by providing this option, but for legacy codebases that want to start migrating to bootstrap, this is a good start. |
I would leave it as is. I have found it no issue to go into the third party css and adjust the math to include padding and borders, it's actually easier and works better. I've done this with about 15 different third party css files for sliders and fancyBox. |
I would also leave it as is. It's not such a huge pain to go back to content-box when using third party scripts: .fancyPlugin,
.otherPlugin {
*,
*:before,
*:after {
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
} |
Thanks for clarifying, it's good know to know Bootstrap isn't meant to be used with third party plugins, helps explain this practice to my users. Hopefully Bootstrap 4 will catch up with Foundation and realize that this practice, while being more work on the Bootstrap end, is better kept within its own namespace. |
Bootstrap is js, html, and css. A simple bit of css used by @renaudleo makes it work with third party plugins. |
@carasmo we know that, the idea here is that with some changes to Bootstrap, nobody has to bother with fixes to make things work. |
I fail to see why any third party would choose the default box sizing over |
@hnrch02 Possibly to support IE7? (Bootstrap doesn't officially support IE7.) |
@cvrebert If support for IE7 is critical a polyfill could be used. |
@hnrch02 Third party scripts not choosing automatically get |
@staaky As Paul Irish mentions in his post, box-sizing is one of the few CSS3 properties with (almost) excellent browser support and it makes working with dimensions in CSS so much easier, so I don't see why a developer would not choose |
@hnrch02 @paulirish actually caused Foundation to define So by mentioning that Bootstrap 3 avoided the global |
@staaky For the record, Foundation 5 still universally resets Again, practicality beats purity here. Sure, being specific helps in the few instances of unexpected collisions, but the consistent behavior for easier sizing of all elements is a huge win. Nothing will change in v3 and I imagine not much will change in v4, unless another selector comes along. |
@staaky I think you're walking against the wind here. If you maintain a third-party widget it's your responsibility to make it robust and function well in all environments (except, perhaps quirks mode). Disqus among others have already dealt with this and baked in their own box-sizing rules to insulate their styles from the host page. I think that's going to be a far more effective route than trying to change the rest of the world. |
@paulirish Can't the same be said for frameworks? Shouldn't they try to do things in a way that conflicts with the least amount of third-party widgets? The reason I'm pointing this out is not to get Bootstrap to move away from |
Framework is the foundation and when the foundation uses box-sizing:border-box the rest of the architecture should adapt to use the the better, forward solution. You can't simply make fluid, responsive layouts with borders with content-box sizing. And since it takes moments to add the the LESS written earlier, and since, hopefully, you're adjusting the background, font, and colors of the widget, this is an odd request. |
@mdo Keep The docs showing how to monkey patch third party code moves the problem to third parties and people using their code, it won't cover every usecase, but I guess that'll have to do for now. Maybe one day we can have a nice conflict free solution and get rid of those docs. |
Hey guys - can't you just use the updated box-sizing technique that doesn't interfere with 3rd-party code? @paulirish actually updated the technique in his article (http://www.paulirish.com/2012/box-sizing-border-box-ftw) in August of last year based on this article: https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice. The new code looks like this:
|
The snippet below can be found in bootstrap.css:
Using this global css reset is fine as long as someone uses Bootstrap exclusively. Once third party scripts come into play this global reset to
border-box
starts messing up layouts.For example, a lot of bug reports I'm getting for my (lightbox and tooltip) scripts concerning layouts being off end up being caused by this practice in Bootstrap. I'd say it's not something that belongs in a framework, unless it's meant to be used without third party scripts.
Foundation used to have this problem. It was fixed very elegantly in 5.0 by using a mixin to add the box-sizing reset to just the components that need it. By not defining it on
*
third party scripts remain unaffected and work out of the box. They can rely on the default box-sizingcontent-box
being in place without anyone having to make css adjustments to reset things back to default.I'm hoping something similar can be done in Bootstrap.
The text was updated successfully, but these errors were encountered: