导航条淡出&滚动时淡出
navbar fadeIn & fadeOut at scrolling
嗨,我正在做一个关于如何使我的导航栏在向下滚动和向上滚动时淡出的搜索,发现很好的主题帮助了我很多下滚动时引导导航条褪色,同时改变文本颜色
亦作http://jsfiddle.net/f5UTL/
问题是它在滚动时不会淡出它只是出现和消失没有动态动画它甚至在移动我的页面在这个过程中如果有人告诉我我在
哪里出错了我很感激< script >
$(function () {
var header = $('.opaque');
$(window).scroll(function () {
var scroll = $(window).scrollTop();
if (scroll >= 300) {
header.removeClass('opaque').addClass('navbar-fixed-top').fadeIn();
} else {
header.removeClass('navbar-fixed-top').fadeOut().addClass('opaque');
}
});
});
< /script>
.navbar-fixed-top {
background-color: rgba(128,128,128,1);
transition: background-color all 2s;
-webkit-transition: background-color all 2s;
-moz-transition: background-color all 2s;
-o-transition: background-color all 2s;
}
.navbar-fixed-top .opaque {
background-color: rgba(128,128,128,0);
transition: background-color all 2s ;
-webkit-transition: background-color all 2s ;
-moz-transition: background-color all 2s ;
-o-transition: background-color all 2s ;
}
这是您想要实现的简化版本。
$(function() {
//caches a jQuery object containing the header element
var header = $('#nav');
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= header.height()) {
header.fadeOut();
} else {
header.fadeIn();
}
});
});
希望它能帮助你继续。
更新小提琴。
相关文章:
- 在容器中心滚动时淡出
- jQuery淡出后停止自动滚动
- 如何使部分在滚动中淡入淡出
- 试图让我的引导程序navabar背景淡出滚动在我的wordpress主题
- 向上滚动导航栏背景淡出
- 使用CSS不透明度和Javascript在滚动时淡入淡出
- 根据滚动淡入或淡出
- jQuery 在滚动时淡出 - 我做错了什么
- 淡入和淡出在窗口滚动后发生多次
- 网站内容在淡出的标题上滚动
- 当您离开页面底部 100 像素时,淡出“滚动到顶部”按钮
- j查询基于滚动的淡入和淡出
- 淡入和淡出闪烁,如果滚动速度很快
- Jquery滚动淡出
- 修复滚动时延迟的jquery淡入淡出
- 滚动后,尝试在导航栏的背景色中淡入淡出
- 滚动时淡入淡出;不能在移动浏览器中工作
- 使用淡入淡出滚动jQuery效果的2列浮动画廊
- 导航条淡出&滚动时淡出
- Iframe音频淡出滚动