We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
事实上,所有HTML元素可以看作盒子。在 CSS 中,==box model== 这一术语是用来设计和布局时使用。 而这个盒子,由四个部分组成:
box-sizing: conent-box; 当我们对一个元素设置他的width和height的时候,标准盒模型只是对content(蓝色部分)设置了宽高,那么这个元素真正的宽高就还要加上他的padding(内边距)border(边框)margin(外边距)。 公式:
box-sizing: conent-box;
box-sizing: border-box;
当我们对一个元素设置他的width和height的时候,怪异盒模型把整个盒子看成是一个整体。给整个盒子一个宽高。如果你还给盒子设置了额外的边距和边框。那么中间的content蓝色部分就要受到挤压,变小。 公式:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
什么是 CSS 的盒模型
事实上,所有HTML元素可以看作盒子。在 CSS 中,==box model== 这一术语是用来设计和布局时使用。
而这个盒子,由四个部分组成:
W3C标准盒模型
box-sizing: conent-box;
当我们对一个元素设置他的width和height的时候,标准盒模型只是对content(蓝色部分)设置了宽高,那么这个元素真正的宽高就还要加上他的padding(内边距)border(边框)margin(外边距)。
公式:
IE盒模型(怪异盒模型)
box-sizing: border-box;
widt = content + padding + border
当我们对一个元素设置他的width和height的时候,怪异盒模型把整个盒子看成是一个整体。给整个盒子一个宽高。如果你还给盒子设置了额外的边距和边框。那么中间的content蓝色部分就要受到挤压,变小。
公式:
总结
因为若不声明DOCTYPE类型,IE浏览器会将盒子模型解释为IE盒子模型,FireFox等会将其解释为W3C盒子模型;若在页面中声明了DOCTYPE类型,所有的浏览器都会把盒模型解释为W3C盒模型。
The text was updated successfully, but these errors were encountered: