width、heigth 设置的是Content box 的宽高
The margin is not counted towards the actual size of the box — sure, it affects the total space that the box will take up on the page, but it space outside the box. The box's area stops at the border — it does not extend into the margin.
margin 不计入盒子的尺寸的计算。
一个div内含一个div,则内部的div以border为界,作为外部div的内容,即content-box。
https://developer.mozilla.org/zh-CN/docs/Learn/CSS/Building_blocks/The_box_model
https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Backgrounds_and_borders
https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Flow_Layout/Block_and_Inline_Layout_in_Normal_Flow
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing
网友评论