简体   繁体   English

控制台具有“无法读取未定义错误的属性”顶部”

[英]Console has “Cannot read property ”top“ of undefined error”

I'm trying to use Bootstrap affix on my navbar to get it fixed on top, once it's been reached by scrolling down. 我试图在导航栏上使用Bootstrap词缀将其固定在顶部,一旦通过向下滚动到达该词缀即可。

HTML: HTML:

<div id="nav-wrapper">
    <div class="container"><!--container-->
        <div class="row" id="navigation"><!--header-->
            <div class="col-md-12"><!--col-md-12-->
                <div class="navbar" id="nav"><!--nav-->
                    <div class="menu-main-menu-container">
                        <ul id="menu-main-menu" class="menu">
                            <li><a href="http://endurancefilmsti.com/">Home</a></li>
                            <li><a href="http://endurancefilmsti.com/about-efti/">About EFTI</a></li>
                            <li><a href="http://endurancefilmsti.com/our-coaches/">Our Coaches</a></li>
                            <li><a href="http://endurancefilmsti.com/blog/">Blog</a></li>
                            <li><a href="http://endurancefilmsti.com/efti-forum/">EFTI Forum</a></li>
                            <li><a href="http://endurancefilmsti.com/contact-us/">Contact Us</a></li>
                        </ul>               
                    </div>       
                </div><!--nav-->
            </div><!--col-md-12-->
            <div class="clearfix"></div>
        </div><!--header-->
    </div><!--container-->
</div>

这是我的控制台的样子

JS: JS:

$(function() {
    $('#nav-wrapper').height($("#nav").height());

    $('#nav').affix({
        offset: { top: $('#nav').offset().top }
    });
});

I have set the position for the nav in my CSS, as required by Bootstrap documentation. 根据Bootstrap文档的要求,我已经在CSS中设置了导航的位置。

#nav.affix {
    position: fixed;
    top: 0;
    width: 100%;
}

#nav > .navbar-inner {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    -webkit-border-radius: 0;
    -moz-border-radius: 0;
    -o-border-radius: 0;
}

Twitter Bootstrap has a class .navbar-fixed-top which you could apply to your div with the class .navbar . Twitter Bootstrap具有.navbar-fixed-top ,您可以使用.navbar类将其应用于div。

I would imagine that would do the trick for you. 我想这会帮到您。

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

相关问题 jQuery 控制台错误:无法读取未定义的属性“top” - jQuery Console Error: Cannot read property 'top' of undefined 控制台错误:未捕获TypeError:无法读取未定义的属性“顶部” - Console Error: Uncaught TypeError: Cannot read property 'top' of undefined 错误:无法读取未定义的属性“顶部” - Error: Cannot read property 'top' of undefined 无法读取未定义的属性“ getRelatedTab”(控制台错误) - Cannot read property 'getRelatedTab' of undefined (Console error) 未捕获的类型错误:无法读取未定义的开发工具控制台的属性“top” - Uncaught TypeError: Cannot read property 'top' of undefined dev tools console 无法读取未定义的属性“ top” - Cannot read property 'top' of undefined` 类型错误:无法读取控制台中生成的未定义错误的属性 - Type error:Cannot read property of undefined error generated in console Uncaught TypeError:无法读取未定义的属性“ top”-滚动错误? - Uncaught TypeError: Cannot read property 'top' of undefined - Scrolling error? 偏移javascript滚动:无法读取未定义错误的属性“ top” - Offset javascript scroll: cannot read property 'top' of undefined error 未捕获的TypeError:无法读取未定义错误的属性“ top” - Uncaught TypeError: Cannot read property 'top' of undefined error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM