elibraryportal Logo

CSS Position

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

There are 5 different position values that is:

  • static
  • relative
  • fixed
  • absolute
  • sticky

It always used to 4 coordinates properties that is :

  • left
  • right
  • top
  • bottom

1) CSS Position: static

The static position always positioned according to the normal flow of the page: It is also knon as default position value.

Example

Test it Now

2) CSS Position: relative

If the position is set to relative, an element can move according to its current position.

Example

Test it Now

3) CSS Position: fixed

You can set left/right & top/bottom coordinates. If the position is set to fixed.

Example 1

Test it Now

Fixed Top Menu Example

Test it Now

4) CSS position: absolute

The absolute position: is used to relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).

Example

Test it Now

5) CSS Position: sticky

The sticky position is used to scroll position.

Example

Test it Now