Web Analytics Made Easy -
StatCounter position:absolute - CodingForum


No announcement yet.


  • Filter
  • Time
  • Show
Clear All
new posts

  • position:absolute

    Hi all.

    I have just been using position:absolute to place images where I want to physically on the screen. It occurred to me what might happen if I was constructing a vertical list of image options which had more than the screen could allow.

    That is, would a scroll bar appear if I defined position:absolute to be beyond the number of pixels on a page.

    Using code such as:

    <img ... position:absolute;top:20;left:10;...>
    <img ... position:absolute;top:50;left:10;...>
    <img ... position:absolute;top:x;left:10;...>

    actually does work fine, with the scrollbar appearing immediately the value x exceeds the dimensions of the screen.

    My questions are:

    1. What are the dimensions, in terms of pixels, of a screen?
    2. Can position:absolute be relied upon to work like this?
    3. If it does, what purpose does position:relative serve?

    Thanks in advance.


  • #2
    the dimensions of a screen are dependant upon a number of factors. that is, it's different for everyone.

    most people have a screen that is either 800 x 600, or 1024 x 768. there are other settings, though.

    if i understand you properly, then yes, you can rely on position: absolute; working like that.

    according to the Guide (see my sig), the difference between relative and absolute is that

    When the position attribute is set to relative, an element is laid out according to the normal flow, and its position is then adjusted relative to its position in the normal flow. The space allocated for the element in the normal document flow remains allocated for it, and the elements on either side of it do not close up to fill in that space, nor are they "pushed away" from the new position of the element.
    [The absloute] value allows you to specify the position of an element relative to its containing element. Absolutely positioned elements are positioned independently of all other elements and are not part of the flow of statically positioned elements.
    hope that helps.
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.