绝对定位始终居中

方法一:(不能微调)

position:absolute;

left:0; right:0; top:0; bottom:0;

margin:auto;

方法二:(可微调)

position:absolute;

top:50%; left:50%;

margin-top:-100px; /*元素高度的一半*/

margin-left:-100px; /*元素宽度的一半*/

方法三:

  1. position: fixed;
  2. top: 0%;
  3. left: 0%;
  4. right: 0%;
  5. bottom: 0%;
  6. margin: auto;
原文地址:https://www.cnblogs.com/shoolnight/p/7388406.html