SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast rutters's Avatar
    Join Date
    Nov 2002
    Location
    ct
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Floats vs Relative Positioning

    Hello Everyone,

    I just wanted to get everyone's take on Float vs Relative Positioning. I have created a new site for my company and have been using floats. I seem to be having issues mainly with the box model in IE.

    Im wondering how many people would line up a sidebar with relative positioning instead of floating a box to the right of a main content box?

    Which would you recommend?

  2. #2
    Object Not Found junjun's Avatar
    Join Date
    Mar 2002
    Location
    northern MI
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I line them up with floats every time.. Usually 2-3 columns with a header and footer which spans their combined width.

  3. #3
    Keep Moving Forward gold trophysilver trophybronze trophy
    Shaun(OfTheDead)'s Avatar
    Join Date
    Nov 2005
    Location
    Trinidad
    Posts
    3,746
    Mentioned
    45 Post(s)
    Tagged
    0 Thread(s)
    I find floats a little unpredictable sometimes, and usually you end up meddling with padding to even things out.

    I use them for simple things, though, because it's A LOT less mark up for simple things.

  4. #4
    Non-Member Egor's Avatar
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    7,305
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Floats. Can't remember the last time I had any issues. The two methods can't really be compared either -- they do different things.

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by rutters
    Im wondering how many people would line up a sidebar with relative positioning instead of floating a box to the right of a main content box?
    Forgive me for being frank but you obviously have no understanding of relative positioning at all but you can be forgiven for it is often used incorrectly by a lot of people .

    Relative positioning is not meant for structural layout and is used for more advanced and subtle effects. In fact you can go years without having to use it at all

    A relatively positioned element is in fact only moved visually but its physical imprint on the page always remains where it was originally. This means that the space it previously occupied is always preserved and everything on the page treats it as if it was still there.

    Once you understand this then you can use it for more subtle or more advanced effects but rarely for structural layout.

    Floats on the other hand are the most flexible tool in the css tollbox and can be used in many situations but again you must understand the rules and also the few float bugs. The faq on floats covers virtually all the known float bugs and armed with these floated layouts can be achieved quite easily.

    Quote Originally Posted by shaun
    I find floats a little unpredictable sometimes, and usually you end up meddling with padding to even things out.
    That's because you haven't taken the time to understand then and learn there little quirks . There is no need to meddle with their padding at all and you are probably trying to do something in an incorrect manner. Floats are removed from the flow and margins on static elements alongside floats should not apply to the float but to their parent container instead, as margins and, background and borders will slide under floats.

    There are of course a few little bugs to contend with (such as the double margin bug) but once these are learned floats will act swimmingly

    While I agree it may be a little frustrating at first (and harder than it should be)the results in the end will be rewarding. At present floats are still the best way of constructing pages and until something better comes along I would advise learning more about them


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
  •