有一个 div#wrapper 元素,高、宽度都未知。它其中有一个宽高都为 100px 的 div#box 元素,请你完成 CSS,使得 div#box 在 div#wrapper 内水平、垂直方向居中。
常规答案
See the Pen
水平垂直居中 by whjin (@whjin)
on CodePen.
方法一
See the Pen
水平垂直居中1 by whjin (@whjin)
on CodePen.
方法二
See the Pen
水平垂直居中2 by whjin (@whjin)
on CodePen.
方法三