larsr
Jun 9th, 2010, 02:13 PM
Hi all,
I'm trying to create a two-column page layout with a gray 1px bar in between, so that it stretches dynamically down the page depending on how much content is displayed.
I wouldn't want to use the old-fashioned way of doing this with tables since I hate tables and am all about DIV's anyway.
At the moment my code is as follows:
<div class="bodywrapper">
<div id="column_left">content in left column</div>
<div id="column_right">content in right column</div>
</div>
and my stylesheet looks like this for the aforementioned id's:
#column_left { float: left; overflow: hidden; width: 220px; padding-right: 10px; }
#column_right { overflow: hidden; border-left: 1px solid #ccc; padding-left: 10px; }
As you can see, there's just two divs and the layout is otherwise perfect but the 1px wide bar only goes down as much as the right column has content.
Now, imagine a situation where, for example, there is only 5 rows of text on the left column and 50 rows of text in the right one, the bar stretches well and all looks swell.
Cool. Now imagine this in reverse - ie. left column has, say, 20 lines of text and and the right one two. The bar isn't stretching down as much as I'd want to and naturally so, because it's in relation to the left column.
Now, I could switch the border declaration from the right column to the left, but should it happen that things would get reversed once again, I'd be in the same situation. The only way I see it working is if I do all this with tables and one, 1px wide TD. I wouldn't like to do that, since as previously said, I hate tables.
I could do a border for both DIV's but depending on which column is longer, the bar would look "broken" halfway.
If I do a third DIV between the left and right column, like so:
<div class="bodywrapper">
<div id="column_left">content in left column</div>
<div id="column_bar"><img src="dot.gif"></div>
<div id="column_right">content in right column</div>
</div>
with CSS as follows:
#column_left { float: left; overflow: hidden; width: 220px; padding-right: 10px; }
#column_bar { float: left; width:1px; height: 100%; background: #ccc }
#column_right { overflow: hidden; padding-left: 10px; }
I do get a 1px wide bar, but also 1px high bar which doesn't go down anywhere.
If I use display:block inside "column_bar" style, my layout screws up.
Does anyone have any clues as to how this might work using plain DIV's and a stylesheet?
I'm trying to create a two-column page layout with a gray 1px bar in between, so that it stretches dynamically down the page depending on how much content is displayed.
I wouldn't want to use the old-fashioned way of doing this with tables since I hate tables and am all about DIV's anyway.
At the moment my code is as follows:
<div class="bodywrapper">
<div id="column_left">content in left column</div>
<div id="column_right">content in right column</div>
</div>
and my stylesheet looks like this for the aforementioned id's:
#column_left { float: left; overflow: hidden; width: 220px; padding-right: 10px; }
#column_right { overflow: hidden; border-left: 1px solid #ccc; padding-left: 10px; }
As you can see, there's just two divs and the layout is otherwise perfect but the 1px wide bar only goes down as much as the right column has content.
Now, imagine a situation where, for example, there is only 5 rows of text on the left column and 50 rows of text in the right one, the bar stretches well and all looks swell.
Cool. Now imagine this in reverse - ie. left column has, say, 20 lines of text and and the right one two. The bar isn't stretching down as much as I'd want to and naturally so, because it's in relation to the left column.
Now, I could switch the border declaration from the right column to the left, but should it happen that things would get reversed once again, I'd be in the same situation. The only way I see it working is if I do all this with tables and one, 1px wide TD. I wouldn't like to do that, since as previously said, I hate tables.
I could do a border for both DIV's but depending on which column is longer, the bar would look "broken" halfway.
If I do a third DIV between the left and right column, like so:
<div class="bodywrapper">
<div id="column_left">content in left column</div>
<div id="column_bar"><img src="dot.gif"></div>
<div id="column_right">content in right column</div>
</div>
with CSS as follows:
#column_left { float: left; overflow: hidden; width: 220px; padding-right: 10px; }
#column_bar { float: left; width:1px; height: 100%; background: #ccc }
#column_right { overflow: hidden; padding-left: 10px; }
I do get a 1px wide bar, but also 1px high bar which doesn't go down anywhere.
If I use display:block inside "column_bar" style, my layout screws up.
Does anyone have any clues as to how this might work using plain DIV's and a stylesheet?