CSS Positioning

Discussion in 'CSS' started by Killerbee, Jun 29, 2008.

  1. #1
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    Killerbee, Jun 29, 2008 IP
  2. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #2
    kk5st, Jun 29, 2008 Set Best Answer IP
  3. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Though I think surely, if this box isn't sitting where you want it to while using asbolute positioning, you likely just don't know where it's referencing to.

    When you asbsolutely positioning something, those coordinates you give it are based on the nearest positioned parent or ancestor. If you have no positioned parents, the body (basically, the screen) becomes the reference-- starting at the top left corner of the screen.

    But if there's a positioned parent somewhere, then the top left corner of that box is used! Not the screen.

    <div style="position: relative;">
    <div style="position: asolute; left: 200px; top: 5px;">
    stuff in the div
    </div>
    </div>

    The first div has a position. Thus, the second div will not be 200px left from the screen-- it will be 200px left from the left border of the first div.

    Don't waste your time at w3schools. That site is old and doesn't explain things worth a crap.
     
  4. Killerbee

    Killerbee Guest

    Best Answers:
    0
    #4
    Thanks, Stomme poes. I've think i got it now.
     
    Killerbee, Jun 30, 2008 Set Best Answer IP
  5. Sohan

    Sohan Peon

    Messages:
    2,330
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Sohan, Jun 30, 2008 Set Best Answer IP