zygoma — 2013-01-05T06:08:31-05:00 — #1
Buongiorno from medieval York UK
Ok on this site http://tutorial.davidclick.com/max-2-column.html the footer clears the floated columns with a clear:both; e.g.
Having read a tutorial (which has confused me) they suggest there is another technique i can make the footer clear the floated columns by using overflow hidden e.g:
But alas when i try this the layout breaks So my question is please: "What bit css would i need to add to the #content-container to clear the floated columns & push the footer in place if i did not want to add clear:both; in the footer?"
Any insights welcome
ralphm — 2013-01-05T07:03:03-05:00 — #2
I'm on a mobile now, so can't say why the page breaks, but it shouldn't. Overflow: hidden should work fine, but the common alternative is the "clearfix" method.
ralphm — 2013-01-05T07:05:20-05:00 — #3
Here's a link that detail options, including clearfix. http://pageaffairs.com/notebook/containing-floats
paulob — 2013-01-05T07:16:22-05:00 — #4
You are mixing a few concepts there and I half answered this in your other thread Containing floats and clearing floats are separate issues. You contain floats so that the parent will encompass the floats and you clear elements so that they clear the floated content.
First of all in your current structure you just need to add clear:both to the footer to effect the clearing.
No other fixes or css/html code are needed.
The footer will act as the clearing div itself - it does not need the height :1% and indeed that is dangerous to apply to real element as you may find the content limited to 1% in some cases. (As an aside the height:1% was a common hack to force layout in IE but is much safer to use zoom:1.0 instead even though it is invalid. Its no needed anyway because the element has a width which will already force haslayout).
Don't float the footer either as it is not needed to float.
If your code structure did not contain a footer or if the footer was outside #content-container then in order to make #content-container enclose the two floated columns you would use a containing technique such as the clearfix method or indeed just adding overflow:hidden to #content-container (assuming you don't need visible overflow). Overflow other than visible will contain child floats because it creates a new block formatting context and in that context will automatically take care of its child floats (the same as inline-block, display table, floats and absolutely positioned elements will as they all form new block formatting contexts).
Or using the old fashioned clearfix method you would do this:
This basically puts some generated content after the content in that container and then clears it - just like your footer is already doing.
Or you may want to look at the revised clearfix method.
However your current structure needs neither as you can simply add clear:both to the footer.
zygoma — 2013-01-05T07:24:50-05:00 — #5
Big thank you guys
picnictutorials — 2013-01-05T09:37:12-05:00 — #6
here is all you need for ie8+