Hi everyone. I’m pulling my hair out to fix a floating div problem. I’ve done hours upon hours of searching and trying out different solutions but I’m unable to get any of them to work.
I have a simple 2 column layout, floating divs side-by-side within a container. The right column (#white-box) will have dynamically loaded content in it. I need #white-box to expand to fit this content (#main-content)… but it’s not.
I’d like to post a link to show you the problem, but the forum won’t let me because of spam? Sorry.
Here is my code:
<div id="container">
<div id="sidebar"> {module_menu} </div>
<div id="white-box">
<div class="bl">
<div class="br">
<div class="tl">
<div class="tr">
<div id="main-content">
{tag_pagecontent}
</div>
<div style="clear: both;"></div>
</div>
</div>
</div>
</div>
</div>
<div style="clear: both;"></div>
</div>
And here are my styles:
#container {
position:relative;
text-align: left;
margin: 0px;
width: 770px;
z-index:10;
}
#sidebar {
position:relative;
margin: 0;
padding: 36px 10px 0px 10px;
width: 150px;
height: 594px;
float:left;
}
#white-box {
position:relative;
z-index:25;
float:right;
width:600px;
}
#main-content {
position:relative;
text-align:left;
margin: 8px 16px 16px 16px;
}
.bl {background: url(corner-bl.gif) 0 100% no-repeat #ffffff; width: 600px;}
.br {background: url(corner-br.gif) 100% 100% no-repeat}
.tl {background: url(corner-tl.gif) 0 0 no-repeat}
.tr {background: url(corner-tr.gif) 100% 0 no-repeat; padding:10px}
.clear {font-size: 1px; height: 1px}
.clearfix:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
.clearfix {display:inline-block;}
/* Hide from IE Mac */
.clearfix {display:block;}
/* End hide from IE Mac */
As you can see, I’ve got code for the “clearfix” solution, but I tried it in multiple places and it didn’t seem to work either.
Do you know what I am missing?
THANK YOU!