垂直居中

1. display: table, vertical-align: middle

ABC

2. display: flex, align-self: center

ABC

3. position, top: 50%, margin-top: -height/2

ABC

4. before

ABC

5. transform: translateY(-50%)

ABC

6. line-height: height+childHeight/2, display: inline

ABC

水平居中

1. text-align: center

ABC

2. margin: 0 auto

ABC

3. position

ABC

4. transform: translateX(-50%)

ABC

5. display: flex

ABC

垂直水平居中

1. display: table, text-align: center, vertical-align: middle

ABC

2. display: flex, align-self: center, justify-content: center, align-items: center

ABC

3. position, top: 50%, left: 50%, margin-top: -height/2, margin-left: -width/2

ABC

4. before

ABC

5. transform: translateY(-50%)

ABC

6. line-height: height+childHeight/2, display: inline

ABC