Will Hammar Will Hammar - 1 year ago 40
CSS Question

Is position:absolute always counted from the top of the page?

If I make element inside and give it properties position:absolute;top:10px; it will count the 10px from the top of the page and not inside the .

Is this normal or should I use instead position:relative; or something?

Thanks for all answers!

Answer Source

Absolute is not always related to the border of your page. If you take this as example:

<div class="box1" style="position:relative;">
  <div class="box2" style="position:absolute;top:5;"></div>

The position of box2 would be dependent on the position of box1.