滚动时jquery更改菜单栏高度和徽标

时间:2013-12-20 14:00:54

标签: javascript jquery css3

如何检查用户是否向下滚动? 我在页面顶部有一个带有徽标的菜单栏。 如果用户向下滚动,我想调整大小或更改徽标(更小),更改菜单栏的高度并固定位置。

由于

3 个答案:

答案 0 :(得分:0)

试试这个

window.onscroll = function (e) {  //when window is scrolled
 //change image size and height of menu bar
} 

答案 1 :(得分:0)

试试这个

$(window).on('scroll', function(e) {
    console.log(e);
}

答案 2 :(得分:0)

jsFiddle

$(window).on('scroll', function() {
    $('#navbar').css('position','fixed');
    $('#id').attr('width', '100px');
    $('#id2').css('font-size', '12px');
});

我现在更新了代码,在向下滚动时固定在顶部。