The CSS position property

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 value…

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).


Print Share Comment Cite Upload Translate
APA
Ravi kumar | Sciencx (2024-03-29T09:53:55+00:00) » The CSS position property. Retrieved from https://www.scien.cx/2021/09/04/the-css-position-property/.
MLA
" » The CSS position property." Ravi kumar | Sciencx - Saturday September 4, 2021, https://www.scien.cx/2021/09/04/the-css-position-property/
HARVARD
Ravi kumar | Sciencx Saturday September 4, 2021 » The CSS position property., viewed 2024-03-29T09:53:55+00:00,<https://www.scien.cx/2021/09/04/the-css-position-property/>
VANCOUVER
Ravi kumar | Sciencx - » The CSS position property. [Internet]. [Accessed 2024-03-29T09:53:55+00:00]. Available from: https://www.scien.cx/2021/09/04/the-css-position-property/
CHICAGO
" » The CSS position property." Ravi kumar | Sciencx - Accessed 2024-03-29T09:53:55+00:00. https://www.scien.cx/2021/09/04/the-css-position-property/
IEEE
" » The CSS position property." Ravi kumar | Sciencx [Online]. Available: https://www.scien.cx/2021/09/04/the-css-position-property/. [Accessed: 2024-03-29T09:53:55+00:00]
rf:citation
» The CSS position property | Ravi kumar | Sciencx | https://www.scien.cx/2021/09/04/the-css-position-property/ | 2024-03-29T09:53:55+00:00
https://github.com/addpipe/simple-recorderjs-demo