How to make a div fill its container with 100% width and height?

This question already has an answer here:

  • Make a div fill the height of the remaining screen space 31 answers

  • The reason it's not taking up the entire height is because the parent objects are most likely not 100% as you would like. Place the following code before the container style:

     html,body{
    width: 100%;
    height: 100%;
    }
    

    Be sure to include margin: none; and padding: none; in your initial declarations for html and body :

    html, body {
        position:absolute;
        z-index:1;
        top:0px;
        left:0px;
        margin: none;
        padding: none;
    }
    

    Give a height to editBox as well which is equal to the difference from the height of above element. Set the margin, padding to 0 for the html and body elements for avoiding overflow.

    #editBox {
      height: calc(100% - 30px);
    }
    
    html, body {
      margin: 0;
      padding: 0;
    }
    
    链接地址: http://www.djcxy.com/p/88240.html

    上一篇: 浏览器窗口调整两个div底部div

    下一篇: 如何使一个div填充100%宽度和高度的容器?