troubleshooting Question

div height for only space remaining

Avatar of phasevar
phasevar asked on
CSS
17 Comments1 Solution6306 ViewsLast Modified:
I want to place a scrollable div in a parent div which has absolute positioning.  The parent div has content which takes up a variable amount of space before the child div.  When I set height: 100%, the child div overflows the parent div.  What I want is for the child div to consume the *remaining* room in the parent div after the content in the parent div.  The end result should be the child scrollable div consuming all the room in the parent div (without overflowing) minus the title area at the top. I'm targeting both IE and Firefox for this solution.  Below is sample html:

<html>
<head>
<style>
div#parent {
    position:absolute;
    width: 100;
    height: 100;
    border: 1px solid #333;
}
div#parent span#title {
    font-weight: bold;
}
div#child {
    height: 100%;
    overflow: auto;
    border: 1px dotted red;
}
</style>
</head>
<body>

<div id="parent">
    <span id="title">test</span>
    <div id="child">
        one<br/>
        two<br/>
        three<br/>
        four<br/>
        five<br/>
        six<br/>
        seven<br/>
        eight<br/>
        nine<br/>
    </div>
</div>

</body>
</html>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 17 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros