我无法让navbar在bootstrap中崩溃

时间:2015-12-10 15:47:27

标签: html twitter-bootstrap

我的导航栏不会崩溃,我一直想弄清楚为什么要几个小时。看了几个教程,仍然无法让它工作。我是新手,我很感激帮助!

   <header>
        <nav class="navbar navbar-inverse navbar-static-top">
                <div class="navbar-header">
                    <a href="#" class="navbar-brand">Template by Mixon</a>

                    <button class="navbar-toggle" data="collapse" data-target="collapse">
                        lol
                    </button>

                    <div class="collapse navbar-collapse">
                        <ul class="nav navbar-nav navbar-right">
                            <li><a href="#">Home</a></li>
                            <li><a href="#">Team</a></li>
                            <li><a href="#">About</a></li>
                            <li><a href="#">Contact</a></li>
                        </ul>
                    </div>
                </div>

       </nav>
    </header> 

2 个答案:

答案 0 :(得分:0)

<div class="collapse navbar-collapse">位于navbar-header内,不合适,应该在之后。

更改后

<button class="navbar-toggle" data="collapse" data-target="collapse">
                    lol
                </button>

通过

                <button class="navbar-toggle" data-toggle="collapse" data-target="#myid">
                    lol
                </button>

这是bootply

提取:

   <header>
        <nav class="navbar navbar-inverse navbar-static-top">
                <div class="navbar-header">
                    <a href="#" class="navbar-brand">Template by Mixon</a>

                    <button class="navbar-toggle" data-toggle="collapse" data-target="#myid">
                        lol
                    </button>
                </div>


                    <div class="collapse navbar-collapse" id="myid">
                        <ul class="nav navbar-nav navbar-right">
                            <li><a href="#">Home</a></li>
                            <li><a href="#">Team</a></li>
                            <li><a href="#">About</a></li>
                            <li><a href="#">Contact</a></li>
                        </ul>
                    </div>
       </nav>
    </header> 

答案 1 :(得分:0)

将按钮标记更改为..

<button class="navbar-toggle" data-toggle="collapse" data-target=".collapse">

http://bootply.com/pMPGhwKx3u