Skip to content Skip to sidebar Skip to footer

Div Move Up When Scrolling Down

I've been trying to get a DIV to move up when using the scroll on browser to move down, but I can't find a solution which works. More specifically, for example if I fill a DIV with

Solution 1:

Try something like this:

$(window).scroll(function(){            
    $("#scrollingDiv").stop().animate({ "marginTop": ($(window).scrollTop() + 30) + "px"}, "slow"); 
});

Solution 2:

I don't entirely follow what you are trying to do with the <div> content, but there is an easy way to detect page scrolling with jQuery:

$.scroll(function() {
    alert('Scroll position: ' + $('html').scrollTop());
});

From there, you can position whatever you want, however you want, using this value $('html').scrollTop().

Solution 3:

Maybe I'm misunderstanding but, are you trying to keep your DIV in a fixed position regardless of how far the user scrolls down the page?

If so there's a style for that:

position:fixed

Post a Comment for "Div Move Up When Scrolling Down"