Question: I am trying to stack two divs A and B.

Div A - will be scrollable but its height needs to be determined by the div underneath it, Div B so if the content in Div B changes, and it's height changes the height of Div A also changes.

Div B - needs to be aligned to the bottom of page on top of a absolute positioned footer. Its content needs to be aligned to the bottom.

I've tried using position relative and float by wrapping these divs in a wrapper, but the whole thing breaks when I try to keep the Div B aligned or positioned absolutely above the footer.

I've got a feeling this needs to go back to basics, any help would be greatly appreciated

thanks

Answer: 
Here's a basic example. I *think* I have correctly understood your requirement. This example has them appear to be stacked but in the HTML they are not actually stacked, they are nested. I wasn't sure if you could allow that in your solution but fingers crossed.

Example: <http://jsfiddle.net/jyR2A/1/>

CSS:

```
#divA {overflow-y:scroll;position:absolute;height:100%;top:-100%;background:green;width:100%;}
#divB {position:absolute;bottom:0;background:blue;width:100%;color:white;}

```

HTML:

```
<div id="divB">

    <!-- Div A is nested so we can use divB's height -->
    <div id="divA">
    </div>

    <!-- Div B content -->
    <div id="divBinnerContent">

        Line 1 <br />
        Line 2 <br />
        ..Keep adding more lines to test how it works <br />

    </div>

</div>

```

How it works:

divB is the parent element defining the height of divA. So if we set divB position relative or absolute and place divA inside then we can set divA's height to 100% to give it the height of parent element divB.

Now to position divA we make sure it has position:absolute and set top:-100% which will move it up the same distance as the height of its container divB. Position absolute not only allows us to position it correctly but it also removes it from affecting the height of its parent, divB.

And the content for divB I have made a nice container for it but it is not neccessary. Simply put it anywhere inside divB (but not inside divA) and it will be OK.

You can use the content to define the height,as I have, or use an absolute height set in CSS.

Hope this is what you were after.

Le-roy
I managed to achieve this with help from this question and fiddle.

[Stack div elements in css vertically (with dynamic height)](https://stackoverflow.com/questions/12532398/stack-div-elements-in-css-vertically-with-dynamic-height)
<http://jsfiddle.net/nCrEc/334/>

Essentially the answer was giving my Div A a height without using the height parameter but instead using absolute positioning on top and bottom. Which meant changes to Div B changed the location of the Div A's bottom (oo er) which pushed the middle div up whenever another populates the bottom area. 

```
<div class="con">
    <div class="top"></div>
    <div class="middle"></div>
    <div class="bottom"></div>
</div>

```

then using this CSS

```
.con {
width:200px;
top:50px;
bottom:0;
left:0;
position:absolute;
background:#ff0;
}
.top {
width:200px;
height:20px;
position:absolute;
top:0;
left:0;
background:#f60;
}
.bottom {
width:200px;
height:50px;
position:absolute;
bottom:0;
left:0;
background:#f60;
}
.middle {
overflow-y:auto;
min-height:1px;
position:absolute;
bottom:50px;
top:20px;
left:0;
background:#06f;
}

```