📜  垂直和水平对齐中心 div - CSS 代码示例

📅  最后修改于: 2022-03-11 14:47:30.484000             🧑  作者: Mango

代码示例4
.center {
  height: 200px;
  position: relative;
  border: 3px solid green;
}

.center p {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}