sticky element move outside parent element

So... I don't really have an issue. It's just a question... But, i have always thought an element with position:sticky; cannot move outside the parent element. But i just realized today that it can actually move outside parent element... But this is really strange.

To make position:sticky; element move out from parent element, the parent element needs display:initial;. But the strange thing about this is that as far as i know display:initial; will revert the display value to it's initial value (the default value) but even if you have never changed the display value of the parent element, it the sticky element wont follow until you add display:initial; to parent element.

Can anyone explain this to me because this really makes no sense at all. I am so confused 😂

Here is a codepen example...
https://codepen.io/tok124/pen/LYvYeLo
CodePenTim
...
LYvYeLo
Was this page helpful?