Reputation: 2179
I hope I can describe my problem:
I have a shopping basket div with price information below a header (logo, topnav) on my page. When scrolling down the page, I want the shopping basket div to stop scrolling (position:fixed), when it touches the upper end of the browser...
Does anyone have a keyword for what I'm looking for?
Thanks
Jan
Upvotes: 0
Views: 216
Reputation: 1038
Let's imagine that you have jQuery and your shopping basket has class 'cart'
$(document).on('scroll', function(){
if($(document).scrollTop() >= $('.cart').offset().top){
// Add position:fixed styling (eg. with a specific class)
} else {
// Remove position:fixed styling
}
});
Upvotes: 2