CSS + Float Property Problem

Soldato
Joined
25 Jul 2006
Posts
3,529
Location
Taunton
I have a website that i want to have 2 colums down to represent two different content areas, but when i assign them their float properties the div that both are in just dis-regards their height and so looses the background area and brings the next div up the page instead of staying at the bottom of the page where it should be.
 
You just need to clear the floats.
Put the following in your CSS and then give the parent div class="clearfix"

Code:
.clearfix:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;}
.clearfix {display:inline-block;}
 
erm not sure how its ment to work but it does, i have added them two to the top of the css document and they dont seem to be working well.

do i have to add another div called clearfix and place the two contents area within it?

edit: just re-read, i = idoit..
 
You've got it figured out now?

Code:
<div id="container" class="clearfix">
  <div id="floatLeft"></div> 
  <div id="floatRight'></div> 
</div><!-- end of container -->

the container is your pre-existing parent div.
 
Back
Top Bottom