Q:

Two column layout where width of main content DIV is fluid (using all space available to 100%)

I feel this question has been answered but I searched and searched and no answer seems to deal with dynamic main content width.
I simply want this scenario:
|-|nav|-|main content|-|
Where nav is a DIV and main content is a DIV and both are placed inside another DIV container which has a width of 100%. - is simpy a spacing between the DIVs, a margin.
nav has a fixed width of 300px and "main content" div should always take the rest of the space available (to fill the 100% of the parent div) - without the use of JavaScript.
Also I want to have some margins left and right of each DIV (nav, main content) so that they have some space between them and the "browser border"/body.
I experimented with table, table-cell but the border-collapsing drove me nuts so I am heading back to god old "float: left" and clearfix. This is what I have so far:
<div id="container" class="cf">
    <div id="nav">
        Nav stuff
    </div>    
    <div id="main">
        Main stuff
    </div>   
</div>

#container {
    padding: 0;
    width: 100%;
    background-color: orange;
    min-height: 50px;
}

#nav {
    display: inline;
    float: left;
    min-width: 300px;
    width: 300px;
    margin-left: 10px;
    margin-right: 10px;
}

#main {
    display: inline;
    float: left;
    background-color: green;
    margin-right: 10px;
}

.. /* clearfix stuff omitted (class 'cf') */

So now the problem is, how to make "main content" (#main) fill the rest of the parent (#container). If I use a width of 100% the 100% is of course the full width of the parent and the div will go under the "nav" div. If i use "auto" the same thing happens. It of course works if I pass in a fixed width e.g. in pixels but I don't know the correct pixels in advance and using JS to calculate that seems a bit odd to me.
I've seen a solution where the "nav" was put inside "main" but that leads to problems with the margins. Try to insert a margin to create some space beside a div that is inside another div... I don't think that's anyhow possible in this universe.
Thanks for your help!

A:

Maybe you should create BFC to face this problem.
For example:
#container{
    border: 1px solid red;
}
#nav{
    float: left;
    width: 300px;
    border: 1px solid green;
    height: 200px;

    margin-left: 20px;
    margin-right: 20px;
}
#main{

    overflow: hidden;

    height: 400px;
    border: 1px solid blue;
    margin-right: 20px;
}

overflow: hidden; is the key to create BFC for #main.
JSFiddle : http://jsfiddle.net/yujiangshui/yMFB6/
More about BFC : https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context

