andrewmta
03-16-2007, 12:23 PM
Is it possible? I'll give you an example of my problem and code. I tried searching for an answer but couldn't seem to find a solution. I have a feeling this may be one of the more trafficked CSS problems, so if anyone knows of another thread explaining this please drop me a link.
I'm trying to replace a traditional two column table concept like this:
<table style="border:1px solid #000000;">
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
With a DIV instead, like this:
<style type="text/css">
#container{
border: 1px solid #000000;
}
.columnone{
width: 50%;
position: relative;
float:left;
clear: left;
}
.columntwo{
width: 50%;
border-left: 1px solid #000000;
position: relative;
float:left;
clear: right;
}
</style>
<div id="container">
<div class="columnone">Column 1</div>
<div class="columntwo">Column 2</div>
</div>
The above swap works fine except for two visual problems which may both have the same solution, if one exists.
Using the table, as I add more text content to Column 1, column 2 grows vertically to ensure that column 1 does not spill into the column. In essence as a table, column 2's height is set to 100% of container.
Now I can temporarily fix the problem using the divs by setting both columnone and columntwo's height to height: 100%;, height: auto; may also work.
The problem for me is, that if the content happens to be longer than the display screen of the browser in columnone, the height of the columntwo will end once you begin scrolling down. It seems that when you set height: 100%; it considers 100% to be the visual browser default height and doesn't continue the effect once you start scrolling.
Now I know that this can be fixed by using the mozilla compliant CSS table, but I'm trying to make this cross browser without having multiple versions of the code, or having a div version for firefox and a table for ie.
I'm trying to replace a traditional two column table concept like this:
<table style="border:1px solid #000000;">
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</table>
With a DIV instead, like this:
<style type="text/css">
#container{
border: 1px solid #000000;
}
.columnone{
width: 50%;
position: relative;
float:left;
clear: left;
}
.columntwo{
width: 50%;
border-left: 1px solid #000000;
position: relative;
float:left;
clear: right;
}
</style>
<div id="container">
<div class="columnone">Column 1</div>
<div class="columntwo">Column 2</div>
</div>
The above swap works fine except for two visual problems which may both have the same solution, if one exists.
Using the table, as I add more text content to Column 1, column 2 grows vertically to ensure that column 1 does not spill into the column. In essence as a table, column 2's height is set to 100% of container.
Now I can temporarily fix the problem using the divs by setting both columnone and columntwo's height to height: 100%;, height: auto; may also work.
The problem for me is, that if the content happens to be longer than the display screen of the browser in columnone, the height of the columntwo will end once you begin scrolling down. It seems that when you set height: 100%; it considers 100% to be the visual browser default height and doesn't continue the effect once you start scrolling.
Now I know that this can be fixed by using the mozilla compliant CSS table, but I'm trying to make this cross browser without having multiple versions of the code, or having a div version for firefox and a table for ie.