CSS Position

If You Know the Beauty of Positions then You Can move Any Item any Where

The position property specifies the type of positioning method used for an element.

The position Property

  • static
  • relative
  • fixed
  • absolute
  • sticky

absolute and relative and sticky are most used property

position: static

HTML elements are positioned static by default.

Static positioned elements are not affected by the top, bottom, left, and right properties.

position: relative

An element with position: relative; is positioned relative to its normal position.

By this property item will move, but it will take its own place.

position: absolute

Absolute positioned elements are removed from the normal flow, and can overlap elements.

By this property item will move, but it will not take its own place.

Item will move respect to its global parent i.e. HTML.

position: sticky

An element with position: sticky; is positioned based on the user's scroll position.

position: fixed

An element with position: fixed; is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element.

Here Is the Example with Photo You can see it, how position works

Photo position.png

positions2a.jpg