【发布时间】:2018-02-03 19:31:32
【问题描述】:
首先,对不起我的英语不好。
我有这个网站,顶部有一个公司徽标,下方有一个导航栏。当我滚动经过公司徽标时,我想将导航栏位置更改为顶部。
我尝试用 CSS 改变它:
.navbar-fixed {
position: relative;
height: 56px;
z-index: 1000;
}
到...
.navbar-fixed {
position: top;
height: 56px;
z-index: 1000;
}
在 $(document).ready(function (){}) 上使用 Materialize.js 和下一个算法:
var scroll_start = 0;
var startchange = $('#startchange');
var offset = startchange.offset();
if (startchange.length){
$(document).scroll(function() {
scroll_start = $(this).scrollTop();
if(scroll_start > offset.top) {
$(".navbar-fixed").css('position', 'top');
} else {
$('.navbar-fixed').css('position', 'relative');
}
});
}
但它不起作用。
【问题讨论】:
标签: javascript html material-design materialize