Yes, it is 100% possible to do this without any JavaScript
I updated your fiddle
Markup should be like this
<div class="wrapper"> <div class="outer-scroller"> <div class="scroll-container"> container1 <div class="fixed-header"> fixed </div> </div> </div> <div class="last-container"> container2 </div> </div>
and css
.wrapper { width: 100%; height: 300px; } .outer-scroller { height: 140px; overflow-y: scroll; } .scroll-container { padding-top: 70px; width: 300px; height: 1200px; background: #CCC; } .last-container { width: 300px; height: 600px; background: #FCF; } .fixed-header { background: #F2F2F2; position: absolute; width: 300px; height: 70px; top: 0; pointer-events: none; }
You'll see I've added an outer-scroller div.
The next bit is changing your CSS slightly
The new outer-scroller div is double the height of your fixed-header (for the purposes of this example) and it has an overflow-y: scroll on it.
The container inside there is still the same.
The next change is turning your position: fixed into a position: absolute and then adding padding to the top part of the div you want to scroll in order to push its content "below" the new "fixed" header.
Scrolling over the outer-scroller div then makes its content scroll, and because its height is set with an absolute element on top it then scrolls "under" the fixed header.
Once the bottom of its child content scroll-container is reached, the whole page then continues scrolling, and you get the illusion of the header disappearing.
The last bit is pointer-events: none on the header so that it doesn't scroll away when the cursor is over it (but the div below does)