In brief
sticky is influenced by the offset and by the ancestors that create a scrolling mechanism.
Useful to know
An element with position: sticky; is involved in the normal layout and can be held when a specified offset is reached. For sticking to the top end, the usual starting example is top: 0;. Without an appropriate offset value on the relevant axis, sticky may appear to be an ordinary relative element. [1]
The parental context is also important. Sticky orients itself to the nearest ancestor with a scrolling mechanism, created for example by overflow: auto or hidden. This ancestor is not always the place you expect to scroll. [1]
In case of a problem, inspect the chain of parent elements, available space and top, instead of immediately replacing sticky with fixed. Fixed changes the flow participation and can cover content ; sticky is appropriate when you want a hold within a certain section.
Sources
For further detail and to check the information: