I have one sidebar with code
<section>
<div class="8u">
</div>
<div class="4u">
<div id="sidebar">
<div id="scroller-anchor"></div>
<div id="scroller" style="margin-top:10px; width:270px">
Content Here
</div>
</div>
</div>
</div>
</section>
<footer>Content Footer</footer>
NOw my problem is that when i scroll the screen then sidebar scrolls smoothly but when sidebar reaches at footer then sidebar overlap the footer content. I want that sidebar should remain at last position when footer start is reached.
My JQuery Code to scroll the sidebar is:
//<![CDATA[
$(window).load(function(){
$(function() {
var a = function() {
var b = $(window).scrollTop();
var d = $("#scroller-anchor").offset().top;
var c=$("#scroller");
if (b>d) {
c.css({position:"fixed",top:"50px"})
} else {
if (b<=d) {
c.css({position:"relative",top:""})
}
}
};
$(window).scroll(a);a()
});
});//]]>
Please help here. Link to my JS Fiddle