How to make a scrollable element fill 100% of the remaining height of a parent element?

前端 未结 3 1471
旧巷少年郎
旧巷少年郎 2021-01-14 09:15

I have a container div that is a fixed height. It has some content and another child element. I would like the child element to scroll when it has filled the remaining heigh

3条回答
  •  抹茶落季
    2021-01-14 10:02

    Display:table could be usefull:
    Demo http://jsfiddle.net/GCyrillus/Vedkw/1
    Firefox dislike it, child from display:table-row, behaves like table-cell, logic

    html, body {height:100%;width:100%;margin:0;}
    #container {display:table;height:100%;width:100%;}
    #titlebar, #body {display:table-row;height:100%;}
    /* overwrite height of titlebar */
    #titlebar{height:auto;}
    

    EDIT: digg a little please, THIS is a basic layout and you can use it.b
    Inner content of #body can scroll .

提交回复
热议问题