一般情况下,盒子box-sizing属性默认为content-box.
content-box的情况下
目标是设置总宽高都为400px
1.当div为空div时,只需要有空div+边框
所有现在的400=内容+边框*2(因为左右上下边框都有一根,而宽高是左右上下之和)。
![](https://img-blog.csdnimg.cn/20210722134600775.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L0ExMjNwcGxlUXVlZW4=,size_16,color_FFFFFF,t_70)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<Style>
div{
width:398px;
height:398px;
border:1px solid #8A2BE2;
box-sizing: content-box;
}
</Style>
</head>
<body>
<div></div>
</body>
</html>
2.当div有内容时,
之后写,现在条件不够