【问题标题】:CSS/Jquery Fixed Header + ChangeCSS/Jquery 固定页眉 + 更改
【发布时间】:2012-11-11 01:35:21
【问题描述】:

我想实现这个effect

请注意,当您向下滚动时,标题是如何保持固定但也会发生一些变化的。我该怎么做?

我知道如何使用 CSS 来实现,但想为标题添加更多样式。

【问题讨论】:

    标签: jquery css header scroll fixed


    【解决方案1】:

    查看页面来源即可:

    $(window).scroll(function(){
        if ( $('div.wrapper').width() >= 660 ) {
            if ( $(this).scrollTop() > pos.top+header.height() && header.hasClass('default') ) {
                header.fadeOut('fast', function(){
                    $(this).removeClass('default').addClass('scrolling').fadeIn('fast');
                });
            } else if ( $(this).scrollTop() <= pos.top+header.height() && header.hasClass('scrolling') ) {
                header.fadeOut('fast', function(){
                    $(this).removeClass('scrolling').addClass('default').fadeIn('fast');
                });
            }
        }
    });​
    

    有一个滚动监听器,当事件发生时 - 菜单的类在 .default.scrolling 之间切换

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-23
      • 2014-09-12
      • 2012-01-09
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 2014-11-05
      相关资源
      最近更新 更多