i floating elements on scroll want start floating when reach top of window. has idea?
https://jsfiddle.net/eoopvgmc/13/
$(document).ready(function() { $(document).on('scroll', function() { $('.ads').css({ 'top': $(window).scrolltop() + 'px' }); }) });
you can use little piece of code:
$(document).ready(function() { var offset = $('.ads').offset().top, top; $(document).on('scroll', function() { top = $(window).scrolltop() < offset ? '0' : $(window).scrolltop() - offset + 'px'; $('.ads').css({ 'top': top }); }); });
Comments
Post a Comment