css 居中

ie9+ 自身垂直水平居中:

position:absolute;

top:50%;

left:50%;

transform:translate(-50%,-50%);

ie8+ 自身的垂直水平居中:(设定宽高)

  position: absolute;  
  top: 0; left: 0; bottom: 0; right: 0; 

  50%;  
  height: 50%;  
  overflow: auto;  
  margin: auto;  

父级:

display:table;

子级:

display: table-cell;

vertical-align: middle;


 

webkit 让内容垂直水平居中 :

      display: -webkit-box;
    -webkit-box-orient: horizontal;
    -webkit-box-pack: center;
    -webkit-box-align: center;

moz 让内容垂直居中 : 
    display: -moz-box;
    -moz-box-orient: horizontal;
    -moz-box-pack: center;
    -moz-box-align: center;

原文地址:https://www.cnblogs.com/uh-huh/p/4475627.html