I have a jQuery script below, which causes the div to become floating. (What works, and I have no problem with it).
$(document).ready(function() { ctop = $('#comment').offset().top - parseFloat($('#comment').css('margin-top').replace(/auto/, 0)); }); $(window).scroll(function (event) { // what the y position of the scroll is var y = $(this).scrollTop(); var abottom = $('#individual_second_tier').offset().top - parseFloat($('#individual_second_tier').css('margin-top').replace(/auto/, 0)); // whether that below the form if (y >= ctop) { // if so, ad the fixed class $('#comment').addClass('fixed'); if (y > abottom-$('#comment').height()){ $('#comment').offset({'top': abottom-$('#comment').height()-y}); } else { $('#comment').offset({'top': 0 }); } } else { // otherwise remove it $('#comment').removeClass('fixed'); } var newWidth = $('#comment').parent().width(); $('#comment').width(newWidth); });
You can see it in action here . This is the gray square on the right that says "Poll"
My site is responsive, so when it is under 768 pixels, the polling div moves down below the content of the blog. Thus, the full width of the browser script works fine, but when I resize it, the div div goes haywire.
I am completely ready when it comes to jQuery - I am a great paste-paste instance, but I imagine that there is a fancy way in the existing script to make it turn it off when it matches the media request or browser width so that I can get rid of fixed-floating functionality -div.
If someone wants the local copy to get into a mess, here is a zip file with an html file (the type will look like I use Web fonts).
source share