p {
padding:0px;
margin:0;
background:pink;
}
.horizontal-fix-parent {
position:relative;
height:200px;
background: blue;
}
.horizontal-fix-child {
position:absolute;
left:50%;
transform:translateX(-50%);
}
.vertical-fix-child {
position:absolute;
top:50%;
transform:translateY(-50%);
}
.horizontal-vertical-child {
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
}
绝对定位时利用transform实现居中
最新推荐文章于 2023-11-22 19:57:00 发布