Relative div height

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

    add this to you CSS:

    html, body
    {
        height: 100%;
    }
    

    working Fiddle

    when you say to wrap to be 100%, 100% of what? of its parent (body), so his parent has to have some height.

    and the same goes for body, his parent his html. html parent his the viewport.. so, by setting them both to 100%, wrap can also have a percentage height.

    also: the elements have some default padding/margin, that causes them to span a little more then the height you applied to them. (causing a scroll bar) you can use

    *
    {
        padding: 0;
        margin: 0;
    }
    

    to disable that.

    Look at That Fiddle

提交回复
热议问题