I want to know how you would add a stopping p开发者_运维知识库oint/boundary to a postion:fixed
menu that follows you as you scroll. I wanted to have it stop when you get close to a particular point.
As Saeed said—something like this:
$(document).ready(function() {
$(window).bind('scroll', function(e) {
if ($(this).scrollTop() < SOME_PIXEL_VALUE ) {
$(YOURELEMENT).css({'position': 'fixed', 'top': '25px'});
} else {
$(YOURELEMENT).css('position','absolute', 'top': 'SOME_PIXEL_VALUE);
}
});
});
You should use JavaScript or jQuery and hook to the scroll event. When you got close to the intended point, you should change the CSS or class of your fixed element to suit your needs.
精彩评论