Skip to content
techsnow

Layout

Position

The position property moves elements out of the normal flow of the page.

ValueBehaviour
staticDefault. Normal flow.
relativeNormal flow, but can be nudged with top/left. Also becomes the anchor for absolute children.
absoluteRemoved from flow. Placed relative to the nearest positioned ancestor.
fixedRemoved from flow. Stays in the same spot on screen while scrolling.
stickyNormal until you scroll past it, then sticks.

A badge in the corner of a card

.card { position: relative; }

.badge {
  position: absolute;
  top: 12px;
  right: 12px;
}

A sticky header

header {
  position: sticky;
  top: 0;
  z-index: 10;
}