```
//子元素是行內元素
<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);
}
```
