Clearing Floats?

Discussion in 'HTML & Website Design' started by wd_2k6, May 11, 2008.

  1. #1
    Hi,
    How do I go about clearing a float after the closing of a DIV? For instance I always find myself having to use an extra div to clear the float, is there no other way of doing this?
     
    wd_2k6, May 11, 2008 IP
  2. Bagi Zoltán

    Bagi Zoltán Well-Known Member

    Messages:
    364
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #2
    As far as I remember last time I used br with the clear:both style command, and it worked.
     
    Bagi Zoltán, May 11, 2008 IP
  3. milesbparty

    milesbparty Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I usually create a class for the <br> tag:

    br.clear {
    clear: both;
    }

    Then after my <div> with the float, I use:

    <br class="clear" />

    There may be a better way to do it, but this has always worked for me.
     
    milesbparty, May 11, 2008 IP
  4. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Go to google and type in "Enclose floats" and you'll get Gary's (kk4st) page right away. There are goofy methods like the PIE method (use CSS to make a . which is invisible which clears the float) or overflow: hidden is an easy way discovered by Paul O'Brien at Sitepoint. He discovered that any overflow property that's not the visible value (the default) does the trick, but hidden doesn't give you teh fugly sidebars.
     
    Stomme poes, May 12, 2008 IP