📜  css center div vertical - CSS 代码示例

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

代码示例3
/* center vertically */
/* No Flexbox */
.parent {
  position: relative;
}
.child {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}



/* With Flexbox */

.parent {
  display: flex;
  flex-direction: column;
  justify-content: center;
}