Briefly describe the CSS box model

CSS has two box models

Are

content-box: content box-content is the
border of the box border-box: border box-the border is the border of the box

Formula:
content-box width = content width
border-box width = content width + padding + border

Looking at the figure below, the div set to border-box is obviously much smaller than the content-box. It is generally recommended to use border-box, so that the width and height of the element are easy to calculate during layout.
Insert picture description here

Insert picture description here

Published 38 original articles · praised 17 · views 9016

Guess you like

Origin blog.csdn.net/cainiao1412/article/details/100172458