Content with 100

前端 未结 3 1085
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 20:49

Lets assume I have the following layout (see image below)... I have a header (A) at the top, footer (C) that is always at the bottom and container (B) that is in the middle

3条回答
  •  清歌不尽
    2021-01-01 21:43

    Depending on how your page is set up, it may work if you set height: 100%; for (B) and position: absolute; for the container element. Here is an example:

    HTML:

    CSS:

    #container {
        height: 100%;
        width: 100%;
        background: green;
        position: absolute;
    }
    #header, #footer {
        height: 100px;
        width: 100%;
        background: red;
    }
    #body {
        height: 100%;
        width: 100%;
        background: blue;
    }​
    

    jsFiddle

提交回复
热议问题