简体   繁体   中英

Collapsed bootstrap navbar not working

I have this navbar. It works great in regular screen width, but when collapsed, the mobile navbar button doesn't work. I've tried to find any unclosed divs and other issues but can't identify any. Thanks in advance for any help! Apologies for the beginner question

<nav class="navbar navbar-default" role="navigation">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-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>

    </div>
    <div class="navbar-brand" href="#">
        <div class="text-center">  
            <a href="http://localhost:3000/"><img alt="nav" src="/assets/navbar.png" /></a> 
        </div>
    </div>
    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
        <h4>
            <ul class="nav navbar-nav navbar-left">
                <!--  <li>  <a href="/help">Help</a> </li>-->
                <li>  <a href="/Buy">Buy</a> </li>



            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li>  <a href="/new">Search</a> </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">My purchases<span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li> <a href="/lebron">My profile</a> </li>
                        <li class="divider"></li>
                        <li>  <a href="/Bought">Items bought</a> </li>
                        <li>  <a href="/Sold">Items sold</a> </li>
                        <li class="divider"></li>
                        <li>  <a href="/purchases">Purchase history</a> </li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Settings <span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li>  <a href="/users/edit">Edit my profile</a> </li>
                        <li>  <a href="/myprofile">Manage my profile</a> </li>
                        <li class="divider"></li>
                        <li class="dropdown-header">GOODBYE </li>
                        <li>  <a data-method="delete" href="/users/sign_out" rel="nofollow">Logout</a> </li>
                    </ul>
                </li>

    </div><!-- /.navbar-collapse -->
</nav>
</h4>

Clean-up your HTML and it should work fine. There are several missing close tags ( /ul , /div ) and the /h4 is closed at the end.

http://bootply.com/ytu2dul2yw

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