【问题标题】:Navbar Fixed To top without content underNavbar Fixed To top without content under under
【发布时间】:2013-12-28 22:08:34
【问题描述】:

我正在尝试在一个学校项目的网站上设置一个粘性导航栏。这里:http://www.divisionforty.com/aloevera/

我不希望内容位于其下方,我的意思是当它滚动时,内容位于其下方,就像它被定位在绝对位置一样。

希望有人可以帮忙,

丹佛

【问题讨论】:

    标签: jquery css twitter-bootstrap sticky-footer


    【解决方案1】:

    padding-top 分配给.wrapper 类。如果不想隐藏navbar下的内容,可以给padding-top:100px。请参阅this 示例。

    更新:

    请给.offset().top -100 100 是您的javascript中导航栏的高度,如下所示:

    $("#circlediv").click(function() {
     $('html, body').animate({
         scrollTop: $("#benefits").offset().top-100
     }, 2000);
    });
    

     $(function() {
      $('a[href*=#]:not([href=#])').click(function() {
        if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
    
          var target = $(this.hash);
          target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
          if (target.length) {
            $('html,body').animate({
              scrollTop: target.offset().top - 100
            }, 1000);
            return false;
          }
        }
      });
    });
    

    【讨论】:

    • 似乎什么也没做:(
    • 您是否试图避免在导航栏下隐藏内容?如果是,请将 padding-top 设置为 body 或 .wrapper 类。
    • 当您单击其中一个导航选项并滚动时,这就是问题所在。
    • 不客气。如果我的回答对你有帮助,你可以投票。
    猜你喜欢
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 1970-01-01
    • 2016-03-11
    • 2019-08-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    相关资源
    最近更新 更多