Relative div height

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

    add this to your css:

    html, body{height: 100%}
    

    and change the max-height of #block12 to height

    Explanation:

    Basically #wrap was 100% height (relative measure) but when you use relative measures it looks for its parent element's measure, and it's normally undefined because it's also relative. The only element(s) being able to use a relative heights are body and or html themselves depending on the browser, the rest of the elements need a parent element with absolute height.

    But be careful, it's tricky playing around with relative heights, you have to calculate properly your header's height so you can substract it from the other element's percentages.

提交回复
热议问题