问题描述
*{
box-sizing: border-box;
}
这是个好主意吗?任何缺点?
Is this a good idea? Any drawbacks?
我觉得这非常有用,当我想要一个元素有100%和一些内部填充。因为我不必为填充添加另一个元素:/
I find this very useful when I want an element to have 100% and some inner padding. Because I don't have to add another element inside for the padding :/
推荐答案
我已经开始使用这个几乎总是。
I have started to use this almost always.
优惠,
您不需要计算出CSS框
You do not need to calculate out the CSS box-model anymore.
您可以轻松地添加大型 padding
到对象,而无需重新修正高度/
You can easily add large padding
to an object without have to re-fix your height/width
更快的编码你的CSS(查找SASS,如果你没有)
Faster coding of your css (look up SASS if you have not)
,
IE7及以下版本不支持,谁在乎?有些人很遗憾。
IE7 and below have no support, who cares right? Some sadly do.
IE8及以上只有部分支持。
IE8 and up have only partial support.
如果我不想让一切都有它,那么
This is how I go about this if I don't want everything to have it,
div, li, p {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
}
我添加了我知道此属性,并防止每个对象拥有该属性。
I add the elements that I know will utilize this property and to prevent every object from having that property.
这篇关于* {box-sizing:border-box}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!