17
I’ve read a lot about debates between using or not using the property box-sizing: border-box;
as follows:
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
I know that it is very influential, especially in the elaboration of the layout, as interaction between borders, paddings, etc.
But why use it this way? Or why not use it? Once you are applying the style to all elements.
In some cases I used, I could notice an immense repetition of the properties when the DOM hierarchy was deep.
If it is not used this way, the correct thing would be to define only in the properties I will need?
Or rather, what is the real function of the property box-sizing
? And what, in fact, is the best way to use this function?
I always use by default in all projects. Particularly I think a bag have to calculate in hand the size that the div will have to stay just because I put a border or a padding
– Wallace Maxters
So. I tried to start a layout without using this definition, because the repetition of it bothered me. But I’m more bothered by the lack of it than the excess. Even though I’m not sure what the real pros and cons of it are.
– celsomtrindade
According to the MDN The box-Sizing CSS property is used to change the standard box model property used to calculate widths (widths) and heights (Heights) of the elements. It is possible to use this property to emulate the behavior of browsers (browser) that do not correctly support the specification of the CSS box model property.
– Lucas Fontes Gaspareto
The Foundation uses both *, and *:after, *:before. And so do I.
– Danylo Santoro
I understand that the use of * or does not give an interesting discussion, independent of the box-Sizing, by the issues of ease of applying in everything versus the impact on the DOM. The box-Sizing is a property like any other, which is used as needed. In fact it is a property that corrects one of the largest ***adas of w3c in my view (that IE was the only browser to do what was sensible).
– Bacco
Complementing: if you are going to use *, you have a much better proposal in this article here, which changes the whole HTML box, and inherits in the rest of the elements (
inherit
): https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/– Bacco
@Bacco Very well put! So far it seems to me the best method to use. What I thought would get in the way of, or not be the best practice, was the fact that I repeated the property in a, say, "out-of-control" way. I’ll see what I can assemble on top of that concept!
– celsomtrindade
I only use it when necessary. I don’t apply it to
*
.– Diego Souza