- 平时总结:
- 水平居中:
- 块级:margin-left: auto; margin-right: auto;
- 内联:爸爸身上写 text-align:center;
2、垂直居中:
如果 .parent 的 height 不写,你只需要 padding: 10px 0; 就能将 .child 垂直居中;
如果 .parent 的 height 写死了,就很难把 .child 居中,以下是垂直居中的方法。
忠告:能不写 height 就千万别写 height。
参考链接:https://jscode.me/t/topic/1936/2
2、100% 高度的 afrer before 加上 inline block
这个方法还有一个优化版本
7、flex