1. 已知大小的元素在屏幕窗口水平垂直都居中
- width:数值;
- height:数值;
- position: fixed;
- left:50%
- top:50%
- margin-left: - width/2;
- margin-top: - height/2;
2. 已知大小的子元素在父元素中水平垂直居中
- width:数值;
- height:数值;
- position: absolute;
- left:50%
- top:50%
- margin-left: - width/2;
- margin-top: - height/2;
3. 未知大小的元素在屏幕窗口水平垂直都居中
- position: fixed;
- left:0;
- right:0;
- top:0;
- bottom:0;
- margin:auto;
4. 未知大小的子元素在父元素中水平垂直居中
- position: absolute;
- left:0;
- left:0;
- top:0;
- bottom:0;
- margin:auto;