PHP中文网2017-04-17 11:35:55
Use js to get the window size and element position, and then set the content position according to the obtained values. Pure css can also be used, but it feels not flexible enough
伊谢尔伦2017-04-17 11:35:55
Recommend your own blog: http://blog.csdn.net/zp1996323/article/details/50936259, the effect achieved is vertical centering and horizontal centering
黄舟2017-04-17 11:35:55
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
width:XXpx;
height:XXpx;
黄舟2017-04-17 11:35:55
position: absolute;
left:0;
right:0;
top:0;
bottom:0;
margin:auto;
width:XXpx;
height:XXpx;
这个方法不兼容IE6/7,移动端考虑可以使用。
大家讲道理2017-04-17 11:35:55
1. CSS implementation method (width and height are known in advance): The layer that needs to be centered uses absolute positioning, and combines left, top, margin-left and margin-top to achieve centering.
2. js implementation, I won’t say much about this.