<style>
div{
position: relative;
width: 500px;
height: 500px;
background-color: pink;
}
p{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 200px;
height: 200px;
background-color: purple;
}
</style>
</head>
<body>
<div>
<p></p>
</div>
</body>
用translate让盒子居中
最新推荐文章于 2023-10-10 15:56:39 发布