+ 2

Can anyone explain me the exact difference between absolute and relative positions??

25th Jul 2016, 8:05 PM
Hannah Neek
3 Answers
+ 5
@Samuele, that's incorrect information. And absolute position is NOT the same as fixed position. A relatively positioned element is positioned relative to its normal position. By setting the top, right, bottom, and left properties, the element will be positioned away from its normal position. Other content will not fill the gap left by the element. An element with position: absolute; is positioned relative to the nearest positioned ancestor. If it doesn't have one, it uses the document body, and moves along with page scrolling. (As opposed to a fixed positioned element, which is also positioned relative to the viewport and not to the nearest positioned ancestor). Edit: It should be noted that we are talking about CSS positioning here so that no one gets confused. The asker didn't include a CSS tag and this is the HTML app.
26th Jul 2016, 3:05 AM
ZinC
ZinC - avatar
+ 1
Of Course...Thank you
26th Jul 2016, 1:24 AM
Hannah Neek
0
An absolute position does NOT depend on the size of the visitors screen, for example, if I set an absolute (also called fixed) position at top:56px; it will stay at 56 pixels from the top, no matter how big or small is the screen of the viewer. A relative position depends on the visitor screen, then if I set a div to "width: 100%;", it will take all the width of the screen. If the screen is 10 inches, it will take 10 of them, if its 20, it will take 20 and so on... Hope you understood
26th Jul 2016, 12:05 AM
Samuele Roversi