I have a absolutely position bottom toolbar. I want it to dissapear when the page is fully scrolled to top and appear back when it is scrolled down.
Exactly the behavior of the share option in this site. The share bar in the left with twitter and all is only seen once u scroll to its position, but remains there when you scroll further. How can this be don开发者_如何学运维e?
You need to do something like this:
var $window = $(window),
minimalVerticalBoxOffset = 200;
$window.scroll(function () {
yourBox.css('top', Math.max(minimalVerticalBoxOffset, $window.scrollTop()) + 'px');
});
This code assumes that yourBox
is a jQuery selecition containing an absolutely positioned element (which is the one that should be moved around).
精彩评论