簡體   English   中英

滾動時固定標題和導航欄下的內容

[英]Content under fixed header and navbar when scrolling

我想在網站上滾動時固定標題和導航欄。 我可以將它們固定下來,但是#container div中的內容不會出現在它們下面。

我目前使用以下內容使網站內容顯示在標題下方,但不確定如何計算#header和#navbar ID的邊距。

#header{
    width:100%;
    position:fixed;
    top:0px;
}

#navbar{
    width:100%;
    height:50px;
    margin:auto;
    position:fixed;
    top:120px;
}


$(document).ready(function () {
                    $('#container').css('marginTop', $('#header').outerHeight(true) );

                });

謝謝你的幫助。

 $(document).ready(function () { $('#container').css('marginTop', $('#header').outerHeight(true) + $('#navbar').outerHeight(true) ); }); 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM