在W3C模型中: 总宽度 = margin-left + border-left + padding-left + width + padding-right + border-right + margin-right
在IE模型中: 总宽度 = margin-left + width + margin-right
在CSS3中引入了 box-sizing 属性, 它可以允许改变默认的CSS盒模型对元素宽高的计算方式.
共包括两个选项:
content-box:标准盒模型,CSS定义的宽高只包含content的宽高。(默认)
border-box:IE盒模型,CSS定义的宽高包括了content,padding和border
实例:
(con1设置为box-sizing:border-box,con为默认的content-box)
1
2
3
4
5 .con{width: 100px; height: 100px;background- color:royalblue;
6 border:1px solid red; padding: 10px;}
7 .con1{box-sizing: border- box;}
8
9
10
11
查看更多关于css3:盒模型以及box-sizing属性的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did101708