I know about the positioning of div (fixed, absolute and relative). I can attach a fixed div to body so that it will stick to the same position while scrolling body. Here I
That is possible by placing your sidebar absolute and change that to fixed as soon as the windows scroll position passes the bottom.
The CSS:
#sidebar {
height: 120%;
width: 100px;
border: 2px solid blue;
padding: 20px;
margin: 20px;
position: absolute;
top: 0;
}
The jQuery:
$(document).ready(function() {
var bottomPos = $('#sidebar').outerHeight(true) - $(window).height();
$(window).scroll( function() {
if ( $(window).scrollTop() > bottomPos ) {
$('#sidebar').css({'position':'fixed','top':'auto','bottom':'0px'});
} else {
$('#sidebar').css({'position':'absolute','top':'0px'});
}
});
});
And a demo.