DIV center methods and DIV center Methods
1.
1 body {2 text-align: center; 3}
Disadvantage: All content in the body is centered together
2.
. Center {position: fixed; left: 50% ;}
Disadvantage: you need to set the position attribute. When a webpage is complex, it is easy to disturb the page layout, and only the starting position of the element is centered.
3.
1. center {2 width: 500px; 3 margin: 0 auto; 4}
Disadvantage: you need to set the div width.
4.
1. center {2 display:-webkit-flex; 3-webkit-justify-content: center; 4-webkit-align-items: center; 5}
Disadvantage: Html5 support is required.
5.
1. center {2 position: absolute; 3 top: 50%; 4 left: 50%; 5-ms-transform: translate (-50%,-50%); 6-moz-transform: translate (-50%,-50%); 7-o-transform: translate (-50%,-50%); 8 transform: translate (-50%,-50%); 9}
Disadvantage: Html5 support is required.
6.