Navbar下拉菜单(使用引导程序)不起作用

时间:2014-01-02 17:09:29

标签: javascript html css twitter-bootstrap twitter-bootstrap-3

在youtube上关于实施简单导航菜单的教程后,我遇到了一个问题,即显示下拉菜单并折叠其他两个链接。似乎无法弄清楚问题。我是否需要链接到另一个样式表或.js文件?

<html>
    <head>
        <title>None</title>

            <link type="text/css" rel="stylesheet" href="css/bootstrap.css">
    </head>

    <body>

        <!--Fixed Navbar with dropdown -->

        <div class ="navbar navbar-inverse navbar-fixed-top">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle"collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a href="#" class="brand"><img class="logo" src="images/om_logo_2.png"></a>
            </div>

            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">                 
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Opportunities <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="hgv.html">HGV &amp; Lorry Delivery</a></li>
                                    <li><a href="domestic.html">Domestic Parcel &amp; Package Courier</a></li>
                                </ul>
                        </li>

                    <li><a href="#">Vehicle Hire</a></li>
                    <li><a href="#">Contact Us</a></li>
                </ul>
            </div>
        </div>

...

<script src="js/jquery.js"></script>
        <script src="js/bootstrap.js"></script>
    </body>
</html>

2 个答案:

答案 0 :(得分:0)

您没有引用jquery库

就像在引导示例here

中一样
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://code.jquery.com/jquery.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>

答案 1 :(得分:0)

改变这个..

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

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

使用Bootply:http://bootply.com/103529