This content originally appeared on DEV Community and was authored by Ravi kumar
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 :
- static
- relative
- absolute
- fixed
- sticky
And also global values like inherit
, initial
, revert
, unset
can also be applied to position property
Let's talk about each position values one by one :)
static
position: static;
static
in the default position and it's position according to the normal flow of the page. In static top
/bottom
/left
/right
/z-index
property has no effect.
relative
position : relative;
It behaves like a static but when we apply on of these property top
/bottom
/left
/right
/z-index
then element will flow according to these CSS properties.
absolute
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 top
/bottom
/left
/right
.
fixed
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 document, not any particular parent, and are unaffected by scrolling.
sticky
position : sticky;
The element is positioned based on the user's scroll position. A sticky
element toggles between relative
and 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).
This content originally appeared on DEV Community and was authored by Ravi kumar

Ravi kumar | Sciencx (2021-09-04T11:33:37+00:00) The CSS position property. Retrieved from https://www.scien.cx/2021/09/04/the-css-position-property/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.