Ala Ala - 1 year ago 56
CSS Question

Dynamic height for a child div when the position is relative

It seems a duplicated question but unfortunately I didn't find answers for this simple scenario when the


I have a parent div with two child divs:

<div id="content">
<div id="content_rdivider">&nbsp;</div>
<div id="content_right"></div>

where both parent and child divs have a

A Jsfiddle example is HERE

So my question is almost like THIS question but the position is not absolute here.

How do I make the height of
div the same as the height of the parent div?

Answer Source

try this


#content {
    position: relative;
    background-color: #FFF;
    width: 975px;
    padding: 0px 0px 0px 0px;
    background-repeat: no-repeat;
    background-position: bottom left;
    border: solid 1px #d7d7d7;
    border-bottom: none;
    margin-left: auto;
    margin-right: auto;
    direction: ltr;
    overflow: hidden;
    height: auto;
    display: table;
#content_right {
    width: 180px;
    text-align: right;
    display: table-cell;
#content_rdivider {
    width: 10px;
    text-align: center;
    background-color: red;
    position: relative;
    height: 100%;
    display: table-cell;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download