Grow your CSS skills. Land your dream job.

Positioning

  • # October 27, 2008 at 9:15 am

    is relative position better than absolute positioning?
    can u post in detail abt dis topic? nd help me in my course work? m unable to understand dese topic clearly, please could u post me dese dtails….

    # October 27, 2008 at 10:59 am

    One isn’t better than the other, they are totally different types of positioning. You can think of relative positioning as "relative to itself". So if you gave and element left: -5px, it would appear five pixels to the left of where it normally would. With absolute positioning, if you gave it left: -5px, it would be positioned literally like that -5px was a horizontal coordinate, so it would be all the way to the left of the browser window and 5px to the left beyond that.

    It’s important to remember though that you can limit the "scope" of absolute positioning by giving a parent element relative positioning. I know, it’s weird.

    http://css-tricks.com/absolute-position … sitioning/

    http://css-tricks.com/absolute-relative … ey-differ/

    # October 27, 2008 at 6:45 pm

    But why use it at all. why not just use margins and padding to position your elements?

    # October 27, 2008 at 8:06 pm

    When you use absolute positioning, it takes the element outside of the normal flow of the document. This can come in pretty handy. If you a box, 250 pixels by 250 pixels, and you need to attach an image in the lower right corner – regardless of how much content is in the box there are a couple of different ways you can try and go about it, but the easiest, by-far, would be to just set the positioning of the parent container (the box) to relative, and then give the image a position of relative, bottom: 0, and right: 0.

    Look at this page, see the elements attached to the bottom of the page. That would be pretty difficult to accomplish trying to use floats and margins.

    http://www.fnacotton.com/tshirts/catFighter.php

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".