Problem in aligning Div using CSS.

Discussion in 'CSS' started by sandeepbhutani304, Oct 29, 2008.

  1. #1
    Hi,

    I need a layout using CSS.
    I am having 3 divs - div1, div2 and div3

    I want them positioned like

    Div1 Div3
    Div2
    I am not able to do it without using a absolute positioning which I do not need. Can anybody please provide some suggestions what flot/position etc CSS should I apply

    Thanks in advance
     
    sandeepbhutani304, Oct 29, 2008 IP
  2. LeetPCUser

    LeetPCUser Peon

    Messages:
    711
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There are a few ways you can do this, but you will have to specify width for all. I recommend the code below.

    
    #left
    {
     float:left;
     width:x;
    }
    
    #Div1
    {
     float:left; 
     width:x;
    }
    
    #Div3
    {
     float:left; 
     width:x;
    }
    
    #Div2
    {
     float:left;
     width:x;
    }
    
    <div id="left">
     <div id="Div1"></div>
     <div id="Div3"></div>
    </div>
    <div id="Div2"></div>
    
    Code (markup):
     
    LeetPCUser, Oct 30, 2008 IP
  3. sandeepbhutani304

    sandeepbhutani304 Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thx for reply
    but i dont have a div with id=left. Nor I can specify width as I do not know the size of contents in the divs.
     
    sandeepbhutani304, Oct 30, 2008 IP
  4. skateme

    skateme Peon

    Messages:
    162
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Then create one :)

    Posting a link to the page or just your code would be very helpful..
     
    skateme, Oct 31, 2008 IP
  5. faithnomoread

    faithnomoread Peon

    Messages:
    174
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Then you can just go width:auto or you have to do the math if you want two of the divs to fit next to each other then they have to both add up to 100% of whatever your whole container size is and not over or the second div will move to the next line on it's own. You have to do a little basic math.
     
    faithnomoread, Oct 31, 2008 IP