📜  如何水平居中和垂直居中块 div - CSS 代码示例

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

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

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