SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict vflytrap's Avatar
    Join Date
    Aug 2003
    Location
    Twighlight Zone
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Is Absolute Positioning Lazy CSS?

    I was wondering - often, the only successful complicated XHTML layout I can seem to manage forces me to use absolute positioning in my stylesheets. Is this bad? Is this lazy? Is there "always a solution" in relative positioning? Or is it okay? I'm sure this is something people will have mixed opinions on, but I am really curious as to what everyone thinks. Somehow I feel like maybe I'm not a <em>true</em> XHTML/CSS designer if I use absolute pixel-perfect positioning.

    Thanks
    S*
    _________________________________________
    Rockin' in the free world...
    brilliant nonsensical ramblings

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,367
    Mentioned
    180 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    Absolute positioning is perfectly ok where necessary. Sometimes the only way to achieve a certain layout will be with a mixture of positioning.

    Beginners usually go wrong when they absolutely place everything and then wonder why it's so hard to keep track of everything and why it's not fluid. As absolute elements are removed from the flow the only way to follow them is by using some more positioning etc

    If you can keep everything in the flow that needs to be, it is a lot easier to control and you can still place the elements in relation to each other using margins if necessary. However, most pages will need a mixture of positioning to achieve their layouts.

    It's important to remember that absolutely placed elements can be placed in relation to their parents (if parent has a position defined) and then the absolutely placed element is tied to the parent and will move if the parent also moves.

    On the other hand position:relative is often misused (or misunderstood) and I find very few cases where it's actually needed. (Other than to set a stacking context for an element or set a positioning context where no co-ordinates are needed.)

    The problem arises in that when an element is moved relatively it is only moved in relation to itself and the space it previously occupied is preserved.

    Absolute positioning is just another tool in the box and used in the right place is perfectly acceptable.

    Paul


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
  •