Relative div height

后端 未结 6 1768
自闭症患者
自闭症患者 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:22

    The div take the height of its parent, but since it has no content (expecpt for your divs) it will only be as height as its content.

    You need to set the height of the body and html:

    HTML:

    1
    2
    3

    CSS:

    body, html {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
    }
    .block12 {
        width: 100%;
        height: 50%;
        background: yellow;
        overflow: auto;
    }
    .block1, .block2 {
        width: 50%;
        height: 100%;
        display: inline-block;
        margin-right: -4px;
        background: lightgreen;
    }
    .block2 { background: lightgray }
    .block3 {
        width: 100%;
        height: 50%;
        background: lightblue;
    }
    

    And a JSFiddle

提交回复
热议问题