what is the best way to continue flow?

Discussion in 'CSS' started by winterheat, Jun 18, 2007.

  1. #1
    after using float, I know it is needed to continue the flow if we want the enclosing div to include the whole thing (with the obj being floated)... so i know of

    <br style="clear: both" />

    or

    <div style="clear: both" />

    and some even say it is best to

    <div style="clear: both; height: 1px" />

    is there a standard way to do it, especially with all the browsers being different?
     
    winterheat, Jun 18, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    The second method, <div style="clear: both" />, is as close to standard as you are going to get.

    But I would use:
    <div style="clear: both"></div>

    Maybe even put a spacer or &nbsp; in there.
     
    krt, Jun 18, 2007 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I wouldn't do either one. Inserting structural markup for presentation purposes is akin to committng a mortal sin 99% of the time (you know, like killing someone). Instead, look at the elemetn you need to clear, and apply the style to that instead.
     
    Dan Schulz, Jun 19, 2007 IP
  4. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The problem is, sometimes there is nothing to clear. For example, a div with blue background, and the div includes a photo floating at the left, and a short description at the right. If it is not cleared, then the div with the blue background doesn't enclose the whole photo... i think just the short description is enclosed, looking like 2 div overlapping each other. (IE will enclose the photo anyway, but firefox and safari won't)
     
    winterheat, Jun 19, 2007 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It depends on how the code is written. Got an example?
     
    Dan Schulz, Jun 19, 2007 IP
  6. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Surprisingly, I tried 4 versions and they all behave differently:

    to see the code, go to www (dot) 0011 (dot) com/continue_flow_version1.html

    and replace 1 with 2, 3, 4 afterwards

    [​IMG]

    it looks like the one that always continue the flow is <div>
     
    winterheat, Jun 19, 2007 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That's not even valid HTML. You're missing entire blocks of code that are necessary (such as HEAD, TITLE, BODY...)
     
    Dan Schulz, Jun 19, 2007 IP
  8. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    so what if the <head><body> are there... will they make a difference?
     
    winterheat, Jun 19, 2007 IP
  9. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #9
    It would get the browsers on the same level playing field, which would make it a lot easier to code the way you want.
     
    Dan Schulz, Jun 19, 2007 IP
  10. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    OK, i have changed them all to XHTML 1.0 strict and validated. The results turn out to be the same.
     
    winterheat, Jun 19, 2007 IP
  11. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    that makes it sound like heaven... maybe that's why some people can sit in front of the computer for few hours in a row, not eating, not bathing...
     
    winterheat, Jun 19, 2007 IP
  12. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #12
    What does quoting my signature have to do with anything?
     
    Dan Schulz, Jun 19, 2007 IP
  13. winterheat

    winterheat Peon

    Messages:
    125
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    just smelling the flower on the way to some where
     
    winterheat, Jun 19, 2007 IP
  14. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #14
    Take any of the hasLayout triggers and combine them with overflow:hidden/auto or use the PIE clear method which adds an invisible period at the end of the container.
     
    soulscratch, Jun 19, 2007 IP