Results 1 to 3 of 3

Thread: Side by side divs, one centered?

  1. #1
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Side by side divs, one centered?

    I am having a little difficulty with aligning two divs.

    I have one 800 wide div that has the site content...it needs to be centered at all times.

    The second div is 160 wide and I want it at the same height as the first, but ten pixels to its right.

    This image should visually show it:



    I have tried absolute position 50% 0% for the first with the second as relative..and it overlays it...treid different combinations of float as well.

    What am I doing wrong?

    Thanks in advance

  2. #2
    Join Date
    Feb 2009
    Posts
    303
    Thanks
    18
    Thanked 36 Times in 36 Posts

    Default

    First, you need a container, this should do it:
    Code:
    #container {
    display:block; 
    width:965px; /* 800 + 160 + 5 (space in between)
    margin:0 auto;
    text-align:left;
    }
    And add text-align:center; to your BODY styles. (IE bug)

    For the first DIV, use this:
    Code:
    display:block;
    margin-right:160px; /* Sidebar Width */
    For the sidebar... :
    Code:
    #sidebar {
    float:right;
    display:block;
    width:160px;
    margin-left:5px;
    }
    Then, use this as your HTML:
    Code:
    <div id="container">
      <div id="sidebar">
        Sidebar Content goes in here
      </div>
      <div id="content">
        Main content goes here.
      </div>
    </div>
    Or, you can use the DD Layouts if you want

    For the same height, use the DD Equal Height Script.

    Hope this helps,
    X96
    Alex Blackie, X96 Design
    My Website
    I specialize in: HTML5, CSS3, PHP, Ruby on Rails, MySQL, MongoDB, Linux Server Administration

  3. #3
    Join Date
    Jun 2009
    Location
    Kolkata
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default X96 Web Design

    no brother this not acceptable

    it has to be like this

    ..........[div]

    .......[div][div]

    .[div][div][div][div]

    ....[div][div][div]

    now plz solve
    Last edited by bisunath; 06-11-2009 at 05:50 PM. Reason: it is not shoing properly

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •