Expand a relative positioned element to full container height

Posted by Rajat on Stack Overflow See other posts from Stack Overflow or by Rajat
Published on 2010-03-25T23:23:02Z Indexed on 2010/03/25 23:33 UTC
Read the original article Hit count: 304

Filed under:

Hi,

I have a div directly under the body. My HTML looks like this:

<body>
 <div class="parent"></div>
</body>

And the css I use is this:

.parent {
  border:1px solid black;
  bottom:10px;
  position:relative;
  top:100px;
  width:500px;
}

This div doesnt stretch to the entire viewport/available body height. However, if I change the position to absolute, It does stretch.

Is there a way to get a relative positioned element to stretch to its container element height. I tried height 100% as well and it works but it gives a vertical scrollbar to me as the element is positioned at 100px from TOP.

© Stack Overflow or respective owner

Related posts about css