简体   繁体   中英

Twitter Bootstrap 3 navbar

I'm using Twitter Bootstrap in my website. When I'm trying to make a navbar, I cannot see the collapse button. Here's my code:

<div class="navbar navbar-fixed-top" role="navigation" id="navigation">
    <div class="navbar-inner">
        <div class="container">
            <div class="navbar-header">
                <a class="btn btn-default navbar-toggle" data-toggle="collapse" data-target="collapse">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="gryphicon gryphicon-align-justify"></span>
               </a>
               <a class="navbar-brand" href="/index" id="brand">eTalk</a>
            </div>
            <div class="collapse navbar-collapse" id="navbar-collapse">
                <ul class="nav navbar-nav" id="navi">
                    <li><a href="/index">Etusivu</a></li>
                </ul>
            </div>
        </div>
    </div>
</div>

It works fine in my laptop, but when I view it in my tablet it looks like this: https://imageshack.com/i/pdef92a1j

And in my phone it looks like this: https://imageshack.com/i/pc43413aj

The navigation links disappear. How can I make the collapse button visible?

I've included Bootstrap CSS, JavaScript and latest jQuery.

Any suggestions?

Your problem was in the following line of code:

<span class="gryphicon gryphicon-align-justify"></span>

Which should be:

<span class="glyphicon glyphicon-align-justify"></span>

Demo JSFiddle

The example from the website + your things.

data-target for the toggle link was different than the id of the .collapse element (collapse != navbar-collapse) Now it is just the default bs-example-navbar-collapse-1

In bootstrap pay attention at the class names and the correct hierarchies. Always check their docs first.

<div class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="glyphicon glyphicon-align-justify">Toggle</span>
            </a>
            <a class="navbar-brand" href="/index">eTalk</a>
        </div>

        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav" id="navi">
                <li><a href="/index">Etusivu</a></li>
            </ul>
        </div>
    </div>
</div>

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