How to get a child element to size according to parent's min-height?


In the following fiddle:

I have a yellow content area that has a min-height set to 100% - it's the background div to all pages and should take up at least 100% of the available height. If there's overflow, it expands vertically.

Then, within that yellow container, I have another child div (red) that I would like to take up as much vertical space as its parent. It seems I can't set height because the parent element only has min-height, and setting min-height on the red element doesn't work either.

So right now, the yellow is behaving as I'd like, but the red is not expanding. How can this be achieved with CSS only?


.browser {
    background-color: blue;
    height: 600px;
    width: 200px;
    position: relative;
.innercontent {
    min-height: 100%;
    background-color: red;
    width: 100%;
    color: white;
    padding: 2px;

.content {
    background-color: yellow;
    width: 100%;
    min-height: calc(100% - 30px);
.footer {
    position: absolute;
    bottom: 0px;
    left: 0px;
    width: 100%;
    background-color: orange;
    height: 20px;


<div class="browser">
    <div class="content">
        <div class="innercontent">
            This is the problem - I need this to take up 100% of the remaining yellow space, without setting the parent element's 'height' - only min-height is specified in the parent because I need to make sure that it takes up 100% of the height at least, but allow it to extend vertically if there's any overflow.  
        should not see any yellow
    <div class="footer"></div>
Problem courtesy of: RobVious


Take a look at this

I added this

    box-sizing: border-box;
html, body {
  /* Make the body to be as tall as browser window */
  height: 100%;

and changed some attributes u can see at fiddle

If thats what you want you should read this article I made that based in this use-cases

Solution courtesy of: André Junges


I think this might solve your issue?

I have changed the innercontent to position: absolute

If you have text in the yellow section it will always show. Also, you're going to have to do a bit of fiddling to get your footer positioned correctly since you are going to have an overflowing absolute element. I think a full body position: relative wrapper will solve it.

P.S I don't see why you would need a .content AND a .innercontent if you don't want the .content to show?

This works much better and doesn't give you footer grief:

Discussion courtesy of: stridlinnea

This recipe can be found in it's original form on Stack Over Flow.