[英]How to stop scrollIntoView() from scrolling container to top of page?
[英]How to stop sticky nav from preventing scrolling to top of page
在網站的移動版本上,滾動越過標題后會出現粘性nav
,但是一旦出現這種情況,您就無法向上滾動到頁面的最頂部,因為nav
不會解開。 我需要更改什么才能滾動到頁面頂部?
$(".nav-primary .genesis-nav-menu, .nav-secondary .genesis-nav-menu, .nav-header .genesis-nav-menu, .nav-small .genesis-nav-
// Sticky Navigation
var headerHeight = $('.site-header').innerHeight();
var beforeheaderHeight = $('.before-header').outerHeight();
var abovenavHeight = headerHeight + beforeheaderHeight - 1;
$(window).scroll(function(){
if ($(document).scrollTop() > abovenavHeight){
$('.navigation-container').addClass('fixed');
$('.nav-primary').addClass('fixed');
$('.nav-secondary').addClass('fixed');
} else {
$('.navigation-container').removeClass('fixed');
$('.nav-primary').removeClass('fixed');
$('.nav-secondary').removeClass('fixed');
}
});
你可能想使用position: sticky
而不是 JS 來做你的粘性菜單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.