+ 2
Can anyone explain me the exact difference between absolute and relative positions??
3 Antworten
+ 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.
+ 1
Of Course...Thank you
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