[英]stick left panel to the top on scroll
當頁面向下滾動時,我已經將標題粘貼到瀏覽器的頂部。 當頁面向下滾動時,我還需要凍結左面板。
由於頁眉是水平和全角的,因此很容易使用position:fixed進行操作,但是如果我對左面板使用相同的方法,則無法解決。
除了position:fixed
以外,還有什么辦法嗎?
代碼在這里
//Primary filter and left panel hing
// Check the initial Poistion of the Sticky Header
var stickyHeaderTop = $('.filter-header, .left-panel').offset().top;
$(window).scroll(function(){
if( $(window).scrollTop() > stickyHeaderTop ) {
$('.filter-header, .left-panel').css({position: 'fixed', top: '0px'});
} else {
$('.filter-header, .left-panel').css({position: 'static', top: '0px'});
}
});
我剛剛添加
.left-panel {
display: block;
z-index: 10;
}
而且似乎可以更好地工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.