[英]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.