Filling remaining vertical space

霸气de小男生 提交于 2019-12-04 16:25:27

First, you need to set the height of html and body to 100%. Then if you want to cover the rest of the page with that div you should do something like:

div{
     height: -moz-calc(100% - 732px); //732 = 200 + 532
     height: -webkit-calc(100% - 732px);
     height: calc(100% - 732px);
}

Hope this will help....

You really need to post your html.

I suspect that the problem you are having though could be solved by setting the height of the html and body tags to be 100% too. Like :

html, body{
  height:100%;
}

If the div did indeed obey the height: 100%, it would have the same height as the container, conflicting with the elements above it.

Without using Javascript to compute the height, or note widely supported modern CSS extensions, you must fall back to absolute positioning. The only down side is you must manually enter the top of it.

http://jsfiddle.net/NnD2u/

<div class="container">
    <div class="child1"></div>
    <div class="child2"></div>
</div>

.

.container { height: 500px; background-color: Yellow; }
.child1 { height: 200px; background-color: Green; }
.child2 { background-color: Red; }

.container { position: relative; }
.child2 { position: absolute; bottom: 0; left: 0; top: 200px; right: 0px; }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!