DEV Community

Sowntharya
Sowntharya

Posted on

Position in CSS

Position controls how an element is placed on a webpage.

  1. static - Default position
  2. relative - Moves relative to its original position.
  3. absolute - Positions relative to its nearest positioned parent.
  4. fixed - Stays in the same place on the screen while scrolling.
  5. Sticky - Sticks to screen after reaching a scroll position.
.box {
position : relative;
top : 10px;  //moves down
left : 20px;  //moves right
Enter fullscreen mode Exit fullscreen mode

Top comments (0)