Relative div height

后端 未结 6 1857
自闭症患者
自闭症患者 2021-02-19 06:07

I want to split up the view in four parts. A header at the top, using full page width and fixed height.

The remaining page is split up in two blocks of the same height,

6条回答
  •  孤独总比滥情好
    2021-02-19 06:09

    Basically, the problem lies in block12. for the block1/2 to take up the total height of the block12, it must have a defined height. This stack overflow post explains that in really good detail.

    So setting a defined height for block12 will allow you to set a proper height. I have created an example on JSfiddle that will show you the the blocks can be floated next to one another if the block12 div is set to a standard height through out the page.

    Here is an example including a header and block3 div with some content in for examples.

    #header{
       position:absolute;
       top:0;
       left:0;
       width:100%;
       height:20%;
        }
    
        #block12{
        position:absolute;
        top:20%;
        width:100%;
        left:0;
        height:40%;
        }
        #block1,#block2{
        float:left;
        overflow-y: scroll;
        text-align:center;
        color:red;
        width:50%;
        height:100%;
    
        }
     #clear{clear:both;}
     #block3{
        position:absolute;
        bottom:0;
        color:blue;
        height:40%;
    
        }
    

提交回复
热议问题