CSS盒模型笔记

102 阅读1分钟

盒模型本质上是个盒子,主要有两种:content盒模型(W3C盒模型)和border盒模型(IE盒模型),由css属性box-sizing调控。它包括内容(content)、填充(padding)、边框(border)、边界(margin),border盒模型内容写起来更方便,实现起来相对更加好用。

两种盒模型的区别(宽度包含内容不同):

1.content盒模型(box-sizing:content-box;):宽度(width)=内容(content)。

2.border盒模型(box-sizing:border-box;):宽度(width)=内容(content)+填充(padding)+边框(border)。