单击它时,为什么下拉菜单不在我的导航栏中?

时间:2016-08-12 16:50:07

标签: javascript jquery html css twitter-bootstrap

我正在练习使用Bootstrap 3.3.7创建一个导航栏,当我点击它时下拉列表不起作用。我正确引用了我的脚本,并且我有最新版本的jquery,但它仍然没有动摇。代码如下。有人可以帮忙吗?

!DOCTYPE html>
<html lang="EN-US">
<head>
    <title></title>
    <link rel="stylesheet" href="Styles/bootstrap.min.css" />
</head>
<body>

    <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-ex1-collapse">
                <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="#">Title</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse navbar-ex1-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
            </ul>
            <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
            </form>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="#">Link</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Action</a></li>
                        <li><a href="#">Another action</a></li>
                        <li><a href="#">Something else here</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </nav>
    <script src="Scripts/jquery-3.1.0.min.js"></script>
    <script src="Scripts/bootstrap.min.js"></script>
</body>

1 个答案:

答案 0 :(得分:0)

我认为您没有正确链接您的资源。我尝试了它,它的工作原理。也许是这样的:

<link rel="stylesheet" href="../Styles/bootstrap.min.css" />

您始终可以使用cdn链接进行引导。

https://www.bootstrapcdn.com/

小提琴:https://jsfiddle.net/5f42fkcb/