Starlit Daily

📚 › CSS: style and layout

13. Positioning

position: relative keeps an element in the flow but lets you offset it. position: absolute places it relative to the nearest positioned ancestor. position: sticky keeps an element on screen while you scroll.

Top, right, bottom and left set the offsets.

Show example

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

✍️ Your turn

Make .header stick to the top of the screen while scrolling.

← Back to course