```
//子元素是行内元素
<div id="box">
<span class="child">content</span>
</div>
//样式
#box{
width: fit-content;//让内容充满
margin: auto;
}
```

```
//子元素是块元素
<div id="box">
<div class="child">content</div>
</div>
通过定位,计算距离
#box {
height: 200px;
background: red;
position: relative;
}
.child {
width: 100px;
height: 100px;
background-color: aqua;
position: absolute;
left: calc(50% - 50px);
top: calc(50% - 50px);
}
```

