I need to change the top edge of a fixed div element from margin-top: 200px to the top edge of 0px after reaching the bottom of the page (or 200px from the bottom) using a vertical scrollbar.
And switch back if you scroll up.
I assume javascript / jQuery code does this.
my html / layout code:
<div id="header" style="position: fixed; margin-top: 0px;"> Header content </div> <div id="main"> <div id="left" style="position: fixed; margin-top: 200px;">Google Ads here</div> <div id="right">Content posts here</div> </div> <div id="footer"> Footer content </div>
EDIT: here are some images to make my question clearer.
source share