HTML-how to use css on the mobile terminal to align the horizontal and vertical la s of percentage la S, html-css
The pc end center the horizontal and vertical directions of a pop-up window. It is well calculated when the pop-up window width is high. You only need to use the following css:
#date{ width: 300px; height: 300px; position: absolute; top: 50%; left: 50%; margin-left: -150px; margin-top: -150px;}
But on the mobile end, if the percentage layout is written, the height is difficult to determine, so it will become difficult to center the window. Today, Baidu has encountered this problem and saw the information of this friend, the friend's css code is as follows:
.center{ width:50%; height:30%; position: absolute; top: 50%; left: 50%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
Try it to get the desired effect, but if we remove height: 30% without setting the value of height, you will find that the pop-up window center vertically based on your own content. The main css code is as follows:
.center{ width:50%; position: absolute; top: 50%; left: 50%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);}
The effect is as follows (the pop-up window area is the gray background area ):
In this way, you can get the pop-up window effect that you want to center horizontally and vertically. You can try it. Also, thanks to this friend, it solved my problem ~~