CSS : center form in page horizontally and vertically

后端 未结 6 1611
执念已碎
执念已碎 2020-12-13 01:33

How can i center the form called form_login horizontally and vertically in my page ?

Here is the HTML I\'m using right now:


    
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-13 01:50

    if you use a negative translateX/Y width and height are not necessary and the style is really short

    #form_login {
        left: 50%;
        top: 50%;
        position: absolute;
        -webkit-transform: translate3d(-50%, -50%, 0);
        -moz-transform: translate3d(-50%, -50%, 0);
        transform: translate3d(-50%, -50%, 0);
    }
    

    Example on codepen: http://codepen.io/anon/pen/ntbFo

    Support: http://caniuse.com/transforms3d

提交回复
热议问题