I want a 100% height div with absolutely positioned divs inside it. For whatever reason when I add the child divs, the height of the parent div shrinks to the static content size.
To clarify, I do not want the absolutely positioned elements to be full-height. Just the containing div.
I have (simplified) markup as follows:
<div id="content">
<div id="dashboard">
Some text
<div class="widget"></div>
<div class="widget"></div>
...
</div>
</div>
And the styling:
#content {
min-height: 100%;
}
#dashboard {
min-height: 100%;
height: 100%;
position: relative;
}
.widget {
height: 50px; /* arbitrary */
width: 50px;
position: absolute;
}
I have put #content
and #dashboard
as min-height 100% and height 100% and that works. If I comment out the absolutely positioned divs, both are the full height of the screen.
But when I add the .widget
s, #content
is still full height (good) but #dashboard
becomes only the height of 'some text'. For whatever reason, adding absolutely positioned content to #dashboard
changes its height.
Note (edit)
I don't want
#content
to be 100% height because it needs to grow with content on other pages. I only want #dashboard to be exactly 100% height.
jQuery works, but I'd like to do it with css only
$("#dashboard").height( $("#content").height() );
Also I tried changing the type of display to block or inline for #content
and setting -moz-box-sizing to default because I read it can break min-height for Firefox.
Any idea how to fix this?
Similar but not the same: How to set 100% height of a parent div with absolutely positioned children (not a duplicate)?