CSS How to set div height 100% minus nPx

前端 未结 11 1360
自闭症患者
自闭症患者 2020-12-02 04:17

I have a wrapper div which contans 2 divs next to each other. Above this container I have a div that contains my header. The wrapper div must be 100% minus the height of the

11条回答
  •  不知归路
    2020-12-02 04:59

    great one... now i have stopped using % he he he... except for the main container as shown below:

    and here is the css:

    #divContainer {
        width: 100%;
        height: 100%;
    }
    #divHeader {
        position: absolute;
        left: 0px;
        top: 0px;
        right: 0px;
        height: 28px;
    }
    #divContentArea {
        position: absolute;
        left: 0px;
        top: 30px;
        right: 0px;
        bottom: 30px;
    }
    #divContentLeft {
        position: absolute;
        top: 0px;
        left: 0px;
        width: 250px;
        bottom: 0px;
    }
    #divContentRight {
        position: absolute;
        top: 0px;
        left: 254px;
        right: 0px;
        bottom: 0px;
    }
    #divFooter {
        position: absolute;
        height: 28px;
        left: 0px;
        bottom: 0px;
        right: 0px;
    }
    

    i tested this in all known browsers and is working fine. Are there any drawbacks using this way?

提交回复
热议问题