Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS confused about ‘relative’ and ‘absolute’ position ! Re: confused about ‘relative’ and ‘absolute’ position !

#138690
Nishant
Participant

Thanks to all of you.
I created a [PEN](http://codepen.io/anon/pen/quaKr “”) to understand position and have some questions.

1: ‘**absolute1**’ box and ‘**relative1**’ box both have defined with ‘**top: 30px**’ but ‘**relative1**’ box scaling 30px from border of body and ‘**absolute1**’ box scaling 30px from up above the border why ?

2: when ‘**relative1**’ is defined with **top:30px** then some part of it get behind ‘**relative2**’ so have i scale ‘**relative2**’ same as ‘**relative1**’ every time i scale ‘**relative1**’.

3: How to set ‘**relative1**’ and ‘**relative2**’ so that when scaling ‘**relative1**’, ‘**relative2**’ automatically scale with ‘**relative1**’ ? (will i have to set margin-bottom for ‘**relative1’** for this ?)

4: Half of ‘**absolute2**’ is below border so how to set ‘body’ that always all elements float in ‘body’ ?

5: Last but very important question, when and why use ‘**relative** position’, because i think ‘**absolute** position’ can do everything that ‘**relative**’ does ?