我的目标是首先显示横幅图片然后显示导航菜单,当dec <- decompose(as.ts(hourplot))
plot(dec)
滚动到屏幕顶部时,它会粘在顶部。此外,当<nav>
滚动并粘在顶部时,与横幅图片重叠的site-logo
将显示在导航栏上。
我的问题是将导航部分放在html中的位置。它应该移动到标题部分吗? (在这种情况下,最初将它放在css中的最佳方法是有一个<nav>
元素有几个响应式img源标签?)或者它应该保持现在的位置,并让标题部分为删除或包裹导航?
picture
答案 0 :(得分:0)
来自here
<强> CSS 强>
.navbar-fixed {
top: 0;
z-index: 100;
position: fixed;
width: 100%;
}
<强> JQUERY 强>
$(document).ready(function() {
//change the integers below to match the height of your upper dive, which I called
//banner. Just add a 1 to the last number. console.log($(window).scrollTop())
//to figure out what the scroll position is when exactly you want to fix the nav
//bar or div or whatever. I stuck in the console.log for you. Just remove when
//you know the position.
$(window).scroll(function () {
console.log($(window).scrollTop());
if ($(window).scrollTop() > 550) {
$('nav').addClass('navbar-fixed');
}
if ($(window).scrollTop() < 551) {
$('nav').removeClass('navbar-fixed');
}
});
});