Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make child div expand to parent div

Tags:

css

Hi i am having trouble trying to get my child div expand to the height of the parent div that it is inside of.

Here is the css for the parent div

#wrapper #content {
    border: 1px ridge #999;
    height: auto;
    min-height: 1000px;
    width: 1100px;
    margin-top: 40px;
    margin-right: auto;
    margin-bottom: 30px;
    margin-left: auto;
    float: left;
}

And here is the css for the child div

.tab_container {
    clear: both;
    width: 100%;
    border-right: 1px ridge #999;
    margin-bottom: 20px;
    height: 100%;
}

Any ideas what i can do?

like image 840
Alistair Wise Avatar asked Nov 13 '11 17:11

Alistair Wise


1 Answers

You can do it with the folowing style: (Inspired by this question: CSS - Expand float child DIV height to parent's height)

#content {
    border: 1px ridge #999;
    height: auto;
    min-height: 1000px;
    width: 1100px;
    margin-top: 40px;
    margin-right: auto;
    margin-bottom: 30px;
    margin-left: auto;
    float: left;
    position: relative; /* added */
    width: 100%; /* added */
}

.tab_container {
    border: 1px ridge orange; /* added */
    clear: both;
    width: 100%;
    border-right: 1px ridge #999;
    margin-bottom: 20px;
    height: 100%;
    position: absolute; /* added */
}

Fiddle here

like image 193
Benjamin Crouzier Avatar answered Dec 12 '22 02:12

Benjamin Crouzier