← All tutorials

GoCareerGo Tutorials

CSS Tutorial

Selectors, box model, Flexbox, Grid, animation and responsive design.

position

Controls how an element is positioned in the document — static, relative, absolute, fixed or sticky.

  • static — default; follows normal document flow
  • relative — offset from its own normal position, without removing it from the flow
  • absolute — positioned relative to the nearest positioned ancestor, removed from the flow
  • fixed — positioned relative to the viewport, stays put when scrolling
  • sticky — behaves like relative until a scroll threshold, then sticks like fixed
.sticky-header {
  position: sticky;
  top: 0;
}