Is using relative positioning bad?

Discussion in 'CSS' started by necromancer1976, Jun 20, 2008.

  1. #1
    I've tried to stay away from certain positions (absolute, relative, static, fixed) because someone told me to once but all my problems on a clients site were fixed by using relative positioning and Z index.
     
    necromancer1976, Jun 20, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    Static is what things are by default, and not positioned. Relative, absolute and fixed establish new position contexts.

    Relative elements can be shifted relative to their own natural (static) positions in the flow, and they can provide a position reference for their absolute descendants. There are one or three IE bugs whose cure involves establishing a position context; thus setting relative fixes things. It breaks other things. Setting relative can cause surprises in the stacking order of elements if you don't grok what's going on.

    Absolute is placed by reference to its nearest positioned ancestor; that's why we often need a parent element to be relative.

    Fixed is placed relative to the viewport and is therefore fixed and unmoving when all else scrolls.

    Make http://www.w3.org/TR/CSS21/visuren.html#visual-model-intro your bedtime reading. Haphazard use of position can cause you trouble.

    cheers,

    gary
     
    kk5st, Jun 20, 2008 IP