简体   繁体   中英

Bootstrap collapse mobile navbar not working

I'm working on a Meteor project, and my navigation bar is supposed to have the collapsing functionality that Bootstrap provides. The following is my navigation code:

<!-- Navigation, via bootstrap -->
<nav class="navbar navbar-default navbar-fixed-top">
    <section class="container-fluid">

        <section class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ pathFor 'home' }}"><i class="fa fa-usd"></i>&nbsp;&nbsp;AccountedFor</a>
        </section>

        <!-- collapse? -->
        <section class="collapse navbar-collapse" id="collapse-1">
            <ul class="nav navbar-nav">
                {{#if currentUser}}
                    <p class="navbar-text">|</p>
                    <li><a href="{{pathFor 'categories'}}">Manage Categories</a></li>
                {{/if}}
                <p class="navbar-text">|</p>
                <li><a href="{{pathFor 'about'}}">About</a></li>
            </ul>
            <section class="navbar-right">
                <p class="navbar-text">
                    {{> loginButtons align="right"}}
                </p>
            </section>

        </section> <!-- end collapse -->
    </section>
</nav>

This is what the current bar looks like, after I clicked the button that should be expanding the menu.

导航栏不正确

This is what the bar looks like when it is of adequate width to not require collapse, with all entries visible:

全导航栏

It has no problem showing the applicable toggle button when the size of the window is appropriate, but the collapsing functionality I'm expecting does not happen. Anyone care to offer some advice? Thanks ahead of time:

http://jsfiddle.net/bfo38kb1/ <-- This fiddle illustrates the problem I'm having.

bootstrap.js file is missing in your fiddle.
Including it makes it working.

<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

see this http://jsfiddle.net/bfo38kb1/1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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