CSS layout - Aligning two divs side by side

Posted by Ronnie on Stack Overflow See other posts from Stack Overflow or by Ronnie
Published on 2010-04-26T21:16:39Z Indexed on 2010/04/26 21:23 UTC
Read the original article Hit count: 402

Filed under:
|
|

Hello,

I have a small problem. I am trying to align two divs side by side using CSS, however, I would like the center div to be positioned horizontally central in the page, I achieved this by using:

#page-wrap { margin 0 auto; }

Thats worked fine. The second div I would like positioned to the left side of the central page wrap but I can't manage to do this using floats although I'm sure it is possible.

Maybe its best to show the example of what I am describing:

Layout Problem

I would like to push the red div up alongside the white div.

Here is my current CSS concerning these two divs, sidebar being the red div and page-wrap being the white div:

#sidebar    {
    width: 200px;
    height: 400px;
    background: red;
    float: left;
    }

#page-wrap  {
    margin: 0 auto;
    width: 600px;
    background: #ffffff;
    height: 400px;
    }

Any help would be appreciated.

© Stack Overflow or respective owner

Related posts about css-layout

Related posts about css