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
实际宽度不包括 padding 和 border
padding
border
width = content height = content
IE6 及以下在 怪异模式 下,会把盒子解析为怪异盒子,实际宽度包括 padding 和 border
width = content + padding + border height= content + padding + border
可以随意切换 box-sizing 来告诉浏览器如何解析盒子,该属性有三个值
content-box:
width (或 height) = content
padding-box:
width (或 height) = content + padding
border-box:
width (或 height) = content + padding + border
IE 7 及以下完全不支持 box-sizing 属性,需要 Polyfill
box-sizing
border-box
content-box
padding-box
-webkit
-moz
html { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } *, *:before, *:after { -webkit-box-sizing: inherit; -moz-box-sizing: inherit; box-sizing: inherit; }
https://css-tricks.com/box-sizing/
https://developer.mozilla.org/zh-CN/docs/Web/CSS/box-sizing
https://github.com/Schepp/box-sizing-polyfill
https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model
The text was updated successfully, but these errors were encountered:
No branches or pull requests
# 标准盒模型
实际宽度不包括
padding
和border
width = content
height = content
# 怪异盒子
IE6 及以下在 怪异模式 下,会把盒子解析为怪异盒子,实际宽度包括
padding
和border
width = content + padding + border
height= content + padding + border
# CSS3 box-sizing 属性
可以随意切换 box-sizing 来告诉浏览器如何解析盒子,该属性有三个值
content-box:
width (或 height) = content
标准盒模型padding-box:
width (或 height) = content + padding
border-box:
width (或 height) = content + padding + border
怪异盒模型IE 7 及以下完全不支持
box-sizing
属性,需要 Polyfill# 在 ResetCSS 中设置 border-box
border-box
使得对于单独设置content-box
或padding-box
变得无比方便,因为设置其他类型的盒模型之后,其子盒子都继承此属性box-sizing
属性,但如果需要支持旧版本的浏览器, Safari (< 5.1), Chrome (< 10), and Firefox (< 29),就需要添加-webkit
和-moz
# 参考
https://css-tricks.com/box-sizing/
https://developer.mozilla.org/zh-CN/docs/Web/CSS/box-sizing
https://github.com/Schepp/box-sizing-polyfill
https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model
The text was updated successfully, but these errors were encountered: