Multiple Divs on same line?

Discussion in 'HTML & Website Design' started by Kaizoku, Dec 20, 2007.

  1. #1
    Is there a better way of doing it besides using float? As it beaks the layout.
     
    Kaizoku, Dec 20, 2007 IP
  2. US_MAN

    US_MAN Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    y dont u put another table in the row with multiple columns and put DIVs in columns! !! :-s
     
    US_MAN, Dec 20, 2007 IP
  3. Dimpi

    Dimpi Peon

    Messages:
    191
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ya, US MAN is right, try this .
     
    Dimpi, Dec 20, 2007 IP
  4. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #4
    You mean like?

    
    ... <td><div>Div 1</div></td><td><div>Div 2</div></td> ...
    
    HTML:
    It works, thanks :)
     
    Kaizoku, Dec 20, 2007 IP
  5. US_MAN

    US_MAN Peon

    Messages:
    26
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    yup ;) enjoy
     
    US_MAN, Dec 20, 2007 IP
  6. Trapped

    Trapped Well-Known Member

    Messages:
    1,832
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    130
    #6
    Congrats, you just earned several useless lines on your code. You could of simply float the divs, give them the exact needed width and use a clear element after the floated divs.
     
    Trapped, Dec 20, 2007 IP
  7. martinmarzejon

    martinmarzejon Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Divs within tables, that's funny.

    The floats aren't breaking your layout. Trapped is right, float the divs and use a clearing element after the floated divs.

    How to clear?

    
    <br style="clear:both" />
    
    Code (markup):
    You could simply use the above line of code or take it a step further and assign a class to it while putting the css in your master css file. And no, you don't have to use the BR tag, a DIV will do as well.
     
    martinmarzejon, Dec 20, 2007 IP
  8. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #8
    Ah I see, thanks for the info, I guess you learn something every day :D
     
    Kaizoku, Dec 20, 2007 IP
  9. twistedspikes

    twistedspikes Notable Member

    Messages:
    5,694
    Likes Received:
    293
    Best Answers:
    0
    Trophy Points:
    280
    #9
    If your doing that why even have the divs?

    I don't agree with doing it this way as it's using tables for layout purposes but still thought i'd ask that.
     
    twistedspikes, Dec 20, 2007 IP
  10. minus19

    minus19 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Woah, you shouldn't be using tables for a layout anymore! There are loads of ways to have multiple divs on one line! You can use relative or absolute positioning or floats. They don't break designs if you use them properly with clear. You need to specifiy a with for the divs and make sure they fit within the wrapper, making sure to take you padding and margins into consideration ;)
     
    minus19, Dec 21, 2007 IP
  11. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #11
    The problem has been solved already with clear. I never knew this css style existed :/
     
    Kaizoku, Dec 21, 2007 IP
  12. minus19

    minus19 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    There are a lot more than you'd think and some that exist but shouldn't be used, it can be pretty confusing at first ;)
     
    minus19, Dec 21, 2007 IP
  13. NeoRu

    NeoRu Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    And how can you use absolute positioning for that?
     
    NeoRu, Sep 4, 2010 IP
  14. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #14
    You know, there are older posts you can drag up besides this one from 3 years ago.
     
    drhowarddrfine, Sep 4, 2010 IP