CSS盒模型
1. W3C standard
outer box (element space size)
Element space width = content width + padding + border + margin
Element space height = content height + padding + border + margin
inner box (element size)
Element width = content width + padding + border
Element height = content height + padding + border
2. IE box model
outer box (element space size)
Element space width = content width + margin
Element space height = content height + margin
(content width including padding and border)
outer box (element space size)
Element space width = content width + padding + border + margin
Element space height = content height + padding + border + margin
inner box (element size)
Element width = content width + padding + border
Element height = content height + padding + border
2. IE box model
outer box (element space size)
Element space width = content width + margin
Element space height = content height + margin
(content width including padding and border)
下面这种(box-sizing: border-box;)用的比较多,但是上面的W3Cmodel(box-sizing: centent-box) 是默认值
其次要注意如果要加border的话
border: [border-width ||border-style ||border-color |inherit],(border属性是一个用于设置各种单独的边界属性的简写属性。border可以用于设置一个或多个以下属性的值: border-width, border-style, border-color。)
border-style 默认值是 none,如果不修改,没有边框。