简体   繁体   English

滚动滚动jQuery更改菜单栏的高度和徽标

[英]jquery on scroll change the menu bar height and logo

how can I check if the user scrolls down? 如何检查用户是否向下滚动? I have a menubar at the top of the page with a logo. 我在页面顶部有一个带有徽标的菜单栏。 And if the user scrolls down I want to resize or change the logo (smaller), change the height of the menu bar and make the position fixed. 如果用户向下滚动,我要调整大小或更改徽标(较小),请更改菜单栏的高度并固定位置。

Thanks 谢谢

Try this 尝试这个

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

Try this 尝试这个

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

jsFiddle jsFiddle

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

I updated the code now is fixed to top on scrol down. 我更新了代码,现在固定在最下面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM