it's close.
problems: in IE7 the height:100% doesn't seem to do anything. it works in FF but IE7 it does nothing.
Main Topics
Browse All TopicsHow do I layout divs that will expand to take up the available veritcal space. I have a master table with two columns. In the left column are two divs, on on top of the other, the right column is one div. The information contained in each Div is variable and can differ quite a bit in height, however, what I want is for the divs to expand vertically to the bottom of the table row, so they balance visually. Currently I've been doing it with javascript to very poor effect. It often doesn't really work I suspect due to the differing box models causing my javascript calculations of container heights to be different in different browsers. but I'm not sure. What'd I'd prefer is some magical CSS way to just have the stupid divs expand as they should in the first place. Why is this so hard? It shouldn't be this hard. Should it?
Thanks!
-mb
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you have a div container with all three divs inside, you can do the following:
#divContainer { overflow: auto; background-color: ??;}
The div overflow will fill 100% of largest div. If you know which coloumn will be highest ( the majority of the time) set the bg-color of the divContainer = to the highest div.
Hope this helps!
Mark-b, sorry, I should have been more clear. I was using my own code instead of your code. My code is essentially the same thing just slightly more stuff going on. I'll markup your code and see what happens. I did notice in my code my doctype is different:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
I don't know much about doctypes. Could that me the culprit?
LWWS, thanks for the suggestion. I'll give it a try.
mark-b,
well, no luck. But I did have luck using your code and replicating my problem. I modified slightly to simulate data within the divs and it mucks things up exactly like I'm seing things mucked up. Note I did not want to put heights on the two left divs because theose heights are variable, and their respective proportions of the whole are therefore different, depending on the data. I can't say topLeft height=30% because it's not always 30%, sometimes it's 20% which is a bid difference and would leave a lot of empty space, which is undesireable.
Any thoughts? It seems this shouldn't be so bloody hard, but for some reason it is.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtm
<html xmlns="http://www.w3.org/1
<head>
<style>
.expand td {
position: relative;
height:100%;
margin:0;
padding:0;
border:2px solid green;
}
.expand div {
margin-bottom:5px;
padding:5px;
border:2px solid green;
}
.expand div#topLeft {
background-color:orange;
}
.expand div#bottomLeft {
background-color:yellow;
}
.expand div#main {
height:100%;
background-color:#c6c6c6;
color:white;
}
.expand div#main table#subMain{
background-color:#fff;
color:black;
}
</style>
</head>
<body>
<table class='expand' border='1' width="100%">
<tbody>
<tr>
<td id="one" valign="top">
<div id="topLeft">0<br />1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />0<br /></div>
<div id="bottomLeft">0<br />1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />0<br />0<br />1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />0<br /></div>
</td>
<td id="two" valign="top">
<div id="main">Hello, Table
<table id="subMain">
<tr>
<td>hullo, Div!
</td>
</tr>
</table>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>
The height of the table will be dictated by either the content in the left two divs, or the one on the right, unless specific height and overflows are specified.
Are you using this table for layout because you need to, or because you are trying to solve this problem with it? Can you go with straight CSS without the table?
What is the ideal you are looking for? I'm confused! :)
the divs, actually, are being used only so I can implement nifty corners. The table layout is pretty integral to the site. I've done a lot of searching and it seems just what you said is true: The height of the table will be dictated by either the content in the left two divs, or the one on the right, unless specific height and overflows are specified.
And it seems there's no CSS way around it. At least not that I've found. THere's even a pseudo name for the issue: div columns. So I guess I'm not crazy. I did find a decent Javascript hack (that was like one I tried but it's a better implementation).
Anyway, I appreciate your time. Thanks for trying to help!
Business Accounts
Answer for Membership
by: mark-bPosted on 2007-02-19 at 13:08:40ID: 18566110
Note sure exactly what you are looking for... but maybe something like this?:
l1/DTD/xht ml1-strict .dtd"> 999/xhtml" xml:lang="en">
> > v>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtm
<html xmlns="http://www.w3.org/1
<head>
<style>
.expand td {
position: relative;
height:100%;
margin:0;
padding:0;
}
.expand div {
border: 1px solid red;
}
</style>
</head>
<body>
<table class='expand' border='1' height="500px" width="100%">
<tbody>
<tr>
<td width="50%">
<div style='height:50%;'>a</div
<div style='height:50%;'>b</div
</td>
<td>
<div style='height:100%;'>c</di
</td>
</tr>
</tbody>
</table>
</body>
</html>
-Mark