Shaye Larsen
asked on
Relative container to match height of absolute child
I have an absolute div inside of a relative container. The height of the absolute child div is dynamic and will change depending on the content. I need the relative container's height to stretch with the height of the absolute child.
I have not been able to get this to work. I am hoping there is a simple css trick but javascript is also welcome.
Please help me to find a solution so that the absolute div doesn't stretch outside of the relative container.
Also, the absolute child has 3 divs inside it. Those divs contain the content that stretches.
Thank you in advance!!!
I have not been able to get this to work. I am hoping there is a simple css trick but javascript is also welcome.
Please help me to find a solution so that the absolute div doesn't stretch outside of the relative container.
Also, the absolute child has 3 divs inside it. Those divs contain the content that stretches.
Thank you in advance!!!
<style type="text/css">
.wrapper {
position:relative;
width:900px;
height:300px;
}
.child {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
.inner1 {
width:300px;
height:100%;
}
.inner2 {
width:300px;
height:100%;
}
.inner3 {
width:300px;
height:100%;
}
</style>
<div class="wrapper">
<div class="child1">
<div class="inner1">Content 1</div>
<div class="inner2">Content 2</div>
<div class="inner3">Content 3</div>
</div>
</div>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks! For anyone who is interested see my follow up comment for full implementation.
ASKER
So my markup is as follows:
Open in new window