How do I stop a a sticky div from overlapping a second sticky div when it comes into view? Currently, if I have multiple sticky divs after each other, they all stack until they've reach the final sticky item, then they all move up together, but I want Sticky 1 to stay sticky exactly in the center of the screen until Sticky 2 hits it, then it moves up and Sticky 2 stays in place until Sticky 3 hits it, then it moves up - so no overlapping...
So the next div down is actually the boundary of the sticky div.
Also: Will top:50%
always make it exactly vertically centered?
HTML
<div class="sticky-container">
<div class="sticky-this">
STICKY 1
</div>
<div class="sticky-this">
STICKY 2
</div>
<div class="sticky-this">
STICKY 3
</div>
<div class="sticky-this">
STICKY 4
</div>
</div>
CSS:
.sticky-container {
position:relative;
}
.sticky-this {
position:sticky;
height:1000px;
top:50%
}
Codepen: