下拉菜单不适用于引导程序

时间:2017-05-23 18:34:06

标签: html css twitter-bootstrap

我尝试使用bootstrap做一个小的下拉菜单,但没有成功。这是代码:

<ul class="nav navbar-nav">
                <li>
                    <a href="#">Text</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="logout.php">Logout</a></li>
                    </ul>
                </li>
</ul>

知道它为什么不起作用?感谢。

1 个答案:

答案 0 :(得分:3)

确保加载jQuery,bootstrap.js和bootstrap.css。

<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

小提琴:https://jsfiddle.net/0z36747j/

&#13;
&#13;
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

<ul class="nav navbar-nav">
  <li>
    <a href="#">Text</a>
  </li>
  <li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
    <ul class="dropdown-menu">
      <li><a href="logout.php">Logout</a></li>
    </ul>
  </li>
</ul>
&#13;
&#13;
&#13;