css position - Issues when HTML body element is positioned 'relative' -


on 1 of websites, found body element set position: relative , content inside body seem shifted downwards scale of margin-top css value set on topmost element in body.

  1. why body has css 'position: relative' set? intended fix bug? heard there ie bug not able set absolute positioning of elements.

  2. why 'margin-top' of 'only' first element inside body affects position of every element?

  3. javascript function 'getboundingclientrect()' returns wrong value element not consider margin-top value set on topmost element.

1. why body have css 'position:relative' set? intended fix bug? heard there ie bug not able set absolute positioning of elements.

fc: that's not intended fix bug, because 1 (direct) children of body element has position:absolute. without body having position:relative, child positioned relative canvas (the browser inner window), rather relative body element. see this tutorial ('nested position:absolute') full story. there may have been ie bugs in respect in past, of ie8 ie behaves when comes this.

.
2. why 'margin-top' of 'only' first element inside body affect position of every element?

fc: design. vertical margins affect position of subsequent sibling elements, position:relative; top:20px not. again, see mentioned tutorial full story.

.
3. javascript function 'getboundingclientrect()' returns wrong value element not consider margin-top value set on topmost element.

fc: design, i'm not sure whether interpreting matters correctly. can post code demonstrate it? know should careful method. see this dottoro page full story, including alternatives.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -