Position Sticky

June 18, 2020 By Temani Afif

Below you can find some Stack Overflow posts around the use and the understanding of position:sticky.

Few hints to consider if you face any issue with position:sticky:

  • Check if there is overflow:hidden defined somewhere in your code. It will prevent position:sticky from working if applied to an ancestor element.
  • Don’t forget to set a value of top (or bottom/left/right). There is no default direction for sticky so you need to define it.
  • position:sticky consider the parent element (containing block) as a reference. Always add border around the element and its parent to understand what’s happening. If both have the same dimension then there is no room for a sticky behavior
  • You aren’t obliged to always use 0 with top/bottom/left/right, you can also use different values and even negative ones.