The position property specifies the type of positioning method used for an element and by position property we can manipulate the location of an element.
These are type of position value :
And also global values like
unset can also be applied to position property
Let's talk about each position values one by one :)
static in the default position and it's position according to the normal flow of the page. In static
z-index property has no effect.
position : relative;
It behaves like a static but when we apply on of these property
z-index then element will flow according to these CSS properties.
position : absolute;
The element is removed from the normal document flow and is relatively positioned to its first non-static ancestor. Its final position is confirm by the values of
position : fixed;
The element is removed from the normal document flow like absolutely positioned elements. In fact they behave almost the same, only fixed positioned elements are always relative to the viewport, not any particular parent, and are unaffected by scrolling.
position : sticky;
The element is positioned based on the user's scroll position. A
sticky element toggles between
fixed, depending on the scroll position. It is positioned relative until a given offset position is met in the viewport - then it "sticks" in place (like position:fixed).