In css style (horizontal centering)
1.text-align:center
2.margin set the specific value left and right 3.set
the width + margin left and right of the parent element of the center div to auto, and
vertically center it up and down at will:
1.position:absolute/fixed; +width+height+top:50% +left:50% +transform:(or margin-top+margin-left)
2.position:fixed/absolute;+width+height+top:0+right:0+bottom :0+left:0+margin:auto;
3. The line-height space between each div
4. When you do not know your own height and the height of the parent container (https://www.zhihu.com/question/20543196)
parentElement{ position:relative; } childElement{ position: absolute; top: 50%; transform: translateY(-50%); }
5. If there is only one element under the parent container, and the parent element has a height set
parentElement{ height:xxx; } .childElement { position: relative; top: 50%; transform: translateY(-50%); }