tZ
08-07-2008, 01:53 AM
I stumbled across this problem at work and was wondering other ways in which it can be handled. Normally, when I create a 2 column layout I stick to the below schema.
html
<body>
<div id="content">
<div id="sidemenu" class="column left"></div>
<div id="page-material" class="column right"></div>
</div> <!-- end of content -->
</body>
css
.column.left {
float: left;
width: 180px;
}
.column.right {
margin-left: 180px;
}
Up to this point I have never dealed with a situation where the content inside the #sidemenu div is longer than that of the #page-material. However, when this happens if items are cleared using clear:left; inside #page-material the clearing div will also clear the full height of #sidemenu. This is not what I intend. I only need the clearing div to clear content within #page-material. However, due to CSS limitations it is currently impossible to clear content relative to a certain container.
So what would be the best way to handle this problem? My current solution is just to float everything inside #page-material if I need to float any one thing. I think this is kind of hackish and maybe there is "nicer" way?
The other solution I was contemplating was to float #page-material right and leave the margin to #sidemenu. However, if I did this than the navigation menu which resides inside #sidemenu would be below the content. So this doesn't seem like the most structurally correct approach either.
I was also considering using absolute positioning. However, if I did that than #sidemenu would be taken out of the scope of the wrapper div #content. This because a image is being repeated in the background of #content to create a fake column. Therefore, if #sidemenu falls out of the scope of #content the #content div height will be only be determined relative to page-material not #content.
So I was just wondering if anyone else has ever ran across this dilemma and the solution they arrived at to solve it.
html
<body>
<div id="content">
<div id="sidemenu" class="column left"></div>
<div id="page-material" class="column right"></div>
</div> <!-- end of content -->
</body>
css
.column.left {
float: left;
width: 180px;
}
.column.right {
margin-left: 180px;
}
Up to this point I have never dealed with a situation where the content inside the #sidemenu div is longer than that of the #page-material. However, when this happens if items are cleared using clear:left; inside #page-material the clearing div will also clear the full height of #sidemenu. This is not what I intend. I only need the clearing div to clear content within #page-material. However, due to CSS limitations it is currently impossible to clear content relative to a certain container.
So what would be the best way to handle this problem? My current solution is just to float everything inside #page-material if I need to float any one thing. I think this is kind of hackish and maybe there is "nicer" way?
The other solution I was contemplating was to float #page-material right and leave the margin to #sidemenu. However, if I did this than the navigation menu which resides inside #sidemenu would be below the content. So this doesn't seem like the most structurally correct approach either.
I was also considering using absolute positioning. However, if I did that than #sidemenu would be taken out of the scope of the wrapper div #content. This because a image is being repeated in the background of #content to create a fake column. Therefore, if #sidemenu falls out of the scope of #content the #content div height will be only be determined relative to page-material not #content.
So I was just wondering if anyone else has ever ran across this dilemma and the solution they arrived at to solve it.