I was wondering how I can fix the div at the bottom of the window when it scrolls out of view. I know you can do this with twitter bootstrap, but I don't want to use the library.
So far I have jQuery which I thought would work:
$(window).scroll(function() { if (((($('.show_postQuestion').offset().top + $('.show_postQuestion').height()) - ($(window).scrollTop()+$(window).height())) > 0)) { // Post form off-screen $('.show_postQuestion').addClass('fixed'); } else { $('.show_postQuestion').removeClass('fixed'); } });
The .fixed class is just position:fixed; bottom:0; position:fixed; bottom:0; .
The problem is that if the form scrolls and fixes by itself, it no longer leaves the field of view, and in it the text scroll will be fixed by itself, which will lead to its correction again, blah blah blah and its creation flicker .
I was wondering if anyone has a suggestion on how to fix this or an alternative solution?
Thanks!
source share