.step-img-box::after {
content: "";
display: block;
width: 60%;
/* height:60%; */
padding-bottom: 60%;
background-color: #fdf2e9;
position: absolute;
left: 50%;
top: 50%;
}
仅仅使用 absolute 和 left,top 是无法让元素处在最中间位置,只能让元素的左上角位于父元素的中心:
需要利用 transform: translate(-50%, -50%)
来实现,会将元素进行偏移,第一个参数是纵向,第二个参数是横向,若值是百分数则代表元素本身的高度和宽度。
.step-img-box::after {
content: "";
display: block;
width: 60%;
/* height:60%; */
padding-bottom: 60%;
background-color: #fdf2e9;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 50%;
z-index: -1;
}
相关链接: