position div center horizontal and vertical

后端 未结 2 523
温柔的废话
温柔的废话 2020-12-22 05:28

i would like to center a popup div how can i do that browser friendly????

this is the original a bit to the left.

2条回答
  •  旧时难觅i
    2020-12-22 05:57

    I use this code to center an element in the center of the window viewport:

    html {
      display: table;
      table-layout: fixed;
      width: 100%; 
      height: 100%;
    }
    
    body {  
      display: table-cell;  
      width: 100%; 
      height: 100%;
      vertical-align: middle;
      margin:0;
    }
    
    #center {
      margin: auto;
    }
    

    You will find a full example at this link (Bredele CSS bundle). I think it should work for your popup.

    Olivier

提交回复
热议问题