Your sticky element is working as intended, you can't see it because your container div is as short as the sticky element itself, so as soon as it sticks, the parent container is already scrolled out of view.
If you add the br
tags inside of the parent div then you can see it stick. Once you scroll past the parent then it will scroll with the parent and will not be visible anymore as you can see from your original fiddle. Example on this page https://developer.mozilla.org/en/docs/Web/CSS/position
If you are trying to dock this for the entire page then you just need to place the sticky element under a higher level div, for example a div that contains all page content. Just remember when it sticks it only sticks within the parent container
https://jsfiddle.net/n8Le2tva/3/
HTML
<div class="this-parent-div-is-necessary">
<div class="div-sticky-class">
Test
</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>br/><br/><br/><br/><br/><br/><br/><br/><br/>
<br/><br/><br/><br/><br/>
</div>
This example here https://jsfiddle.net/n8Le2tva/10/ I moved the sticky element out so it sticks to the overall viewport
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…