1.行内元素/行内块元素居中
水平居中: text-align-center
垂直居中: line-height:行高
2. 行元素居中
水平居中: margin: 0 auto(注意,设置auto一定要设置宽度)
3.CSS定位居中
实现步骤: 1.绝对定位
2.水平、垂直边 偏移为50%
3.子级向左上移动自身尺寸的一半
1)左、上外边距为 -尺寸的一半
2)transform: translate(-50%, -50%)
4. flex居中
align-items: center; justify-content: center;