If I understand your question correctly, this should do the trick (although, unfortunately, it is very dependent on JavaScript).
// Fix work column on scroll contentStart = $("#content").offset().top ; contentSize = $("#content").height() ; window.onscroll = function(){ if( window.XMLHttpRequest ) { var position=window.pageYOffset; // calculate the position of the footer and the actual seen window var docViewTop = $(window).scrollTop(); var docViewBottom = docViewTop + $(window).height(); var elemTop = $("#footer").offset().top; if ( position > 300 && !(docViewBottom >= elemTop)) { $('#work').css({'position':'fixed', 'top':'0', 'height':'100vh'}); } else { // if the footer is visible on the screen if(docViewBottom >= elemTop) { $('#work').css({ 'top': 0 - (docViewBottom - elemTop) }); // scroll the
For more information about the calculations, maybe this question at https://stackoverflow.com/a/9/9/9/ is helpful.
Edit: Andrew Haining posted his answer in between my answer, maybe try its link and maybe this is the best (more correct) solution. Unfortunately, I did not update this page when I tested your code in JSFiddle, and I did not see its answer.
If you want to use my script, make sure you can test it with different permissions. It is great for my resolution in JSFiddle, I have not tested others.
efux
source share