CSS: Placing divs left/center/right inside header

Viewed 55340

I've been trying to create a site with the following structure:
desired structure

But I can't seem to get the header correct (e1 left, e2 centered, e3 right). I want the three elements e1, e2 and e3 to be left, middle and right positioned. This is what I'm trying:

<div id="wrapper">
<div id="header">
    <div id="header-e1">
        1
    </div>
    <div id="header-e2">
        2
    </div>
    <div id="header-e3">
        3
    </div>
</div>
<div id="nav">
    links
</div>
<div id="content">
    content
</div>
<div id="footer">
    footer
</div>
</div>

With this css:

#wrapper
{
    width: 95%;
    margin: 20px auto;
    border: 1px solid black;
}

#header
{
    margin: 5px;
}
#header-e1
{
    float: left;
    border: 1px solid black;
}
#header-e2
{
    float: left;
    border: 1px solid black;
}
#header-e3
{

    border: 1px solid black;
}

#nav
{
    margin: 5px;
}
#content
{
    margin: 5px;
}
#footer
{
    margin: 5px;
}

Can someone give me tips to what I can do? The structure is going to be used on a mobile website.

UPDATE

The code I have above gives me this: current result But I want the 2 centered and the 3 on the right side. I don't want to set the width to a percent because the content in the elements may vary, meaning it may be 20/60/20 - 10/80/10 - 33/33/33 or something else.

6 Answers
                        <style type="text/css">
                        body {
                        margin:0;
                        }
                        #header {
                        width:100%;
                        **strong text**margin:auto;
                        height:10%;
                        background-color:red;
                        }
                        #left {
                        width:20%;
                        float:left;
                        #margin:auto auto auto auto;
                        height:100%;
                        background-color:blue;
                        }
                        #right {
                        float:right;
                        width:20%;
                        #margin:auto auto auto auto;
                        height:100%;
                        background-color:green;
                        }
                        #middle {
                        position:relative;
                        left:0;
                        right:0;
                        margin:auto;
                        height:80%;
                        background-color:yellow;
                        width:100%;
                        }
                        #middle1 {
                        width: 80%;
                        margin:auto;
                        height:45%;
                        background-color:black;
                        }
                        #middle2 {
                        width: 80%;
                        margin:auto;
                        height:40%;
                        background-color:brown;
                        }
                        #middle3 {
                        width: 80%;
                        margin:auto;
                        height:15%;
                        background-color:orange;
                        }
                        #midmain {
                        width: auto;
                        margin:auto;
                        height:100%;
                        background-color:white;
                        }
                        #footer {
                        width:100%;
                        margin:auto;
                        height:10%;
                        background-color:red;
                        }
                        </style>

now check comment for html design.
Related