How to position the div popup dialog to the center of browser screen?

后端 未结 9 1753
Happy的楠姐
Happy的楠姐 2020-12-13 16:39

I need to position div popup to the center of browser screen ( no matter what size the screen is). And I want to keep the position as absolute as I don\'t want to move the p

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 17:07

    Here, this ones working. :)

    http://jsfiddle.net/nDNXc/1/

    upd: Just in case jsfiddle is not responding here is the code...
    CSS:

    .holder{        
        width:100%;
        display:block;
    }
    .content{
        background:#fff;
        padding: 28px 26px 33px 25px;
    }
    .popup{
        border-radius: 7px;
        background:#6b6a63;
        margin:30px auto 0;
        padding:6px;  
        // here it comes
        position:absolute;
        width:800px;
        top: 50%;
        left: 50%;
        margin-left: -400px; // 1/2 width
        margin-top: -40px; // 1/2 height
    }
    

    HTML:

提交回复
热议问题