bigshow1949 2017-07-06 15:55 原文
- content-box:
- padding和border不被包含在定义的width和height之内。对象的实际宽度等于设置的width值和border、padding之和,即 ( Element width = width + border + padding )
- 此属性表现为标准模式下的盒模型。
- border-box:
- padding和border被包含在定义的width和height之内。对象的实际宽度就等于设置的width值,即使定义有border和padding也不会改变对象的实际宽度,即 ( Element width = width )
- 此属性表现为怪异模式下的盒模型。
示例:
-
content-box:
.test1{ box-sizing:content-box; width:200px; padding:10px; border:15px solid #eee; }
![content-box](http://www.w3chtml.com/css3/properties/user-interface/images/content-box.png)
-
border-box:
.test2{ box-sizing:border-box; width:200px; padding:10px; border:15px solid #eee; }
![border-box](http://www.w3chtml.com/css3/properties/user-interface/images/border-box.png)
我的Github
iOS:https://github.com/BigShow1949/BigShow1949
Java:https://github.com/BigShow1949
每周都会更新,求个小星星!
我的QQ:1029883589
QQ群:148279151
推荐阅读