导航下拉列表无效

时间:2014-11-02 11:13:13

标签: html twitter-bootstrap

导航中的下拉列表无效。 html如下。将不胜感激。

<div class="row menu_bg">
    <div class="container">
        <ul class="nav nav-tabs">
       <li class="active"><a href="#">Home</a></li>
       <li><a href="#">SVN</a></li>
       <li><a href="#">iOS</a></li>
       <li><a href="#">VB.Net</a></li>
       <li class="dropdown">
          <a class="dropdown-toggle" data-toggle="dropdown" href="#">
             Java <span class="caret"></span>
          </a>
          <ul class="dropdown-menu">
             <li><a href="#">Swing</a></li>
             <li><a href="#">jMeter</a></li>
             <li><a href="#">EJB</a></li>
             <li class="divider"></li>
             <li><a href="#">Separated link</a></li>

          </ul>
       </li>
       <li><a href="#">PHP</a></li>
    </ul>
    </div>

3 个答案:

答案 0 :(得分:2)

你的html很好,唯一缺少的是jQuery代码和bootstrap js,在你上一个</div>下以相同的顺序添加它们。

<script src="https://code.jquery.com/jquery-1.11.1.min.js" ></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>

答案 1 :(得分:0)

您需要包含bootstrap和jquery库,它们处理下面显示下拉界面的逻辑工作示例:

<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
    </head>
    <body>
        <div class="row menu_bg">
            <div class="container">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="#">Home</a></li>
                    <li><a href="#">SVN</a></li>
                    <li><a href="#">iOS</a></li>
                    <li><a href="#">VB.Net</a></li>
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            Java <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="#">Swing</a></li>
                            <li><a href="#">jMeter</a></li>
                            <li><a href="#">EJB</a></li>
                            <li class="divider"></li>
                            <li><a href="#">Separated link</a></li>

                        </ul>
                    </li>
                    <li><a href="#">PHP</a></li>
                </ul>
            </div>
        </div>
        <script src="https://code.jquery.com/jquery-1.11.1.min.js" ></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
    </body>
</html>

答案 2 :(得分:0)

container内有rowcontainer内有内容,我已更正了。{正确的层次结构是container =&gt; row =&gt; col-??-##. If you put it in any other order, it will malfunction. This should work. I'm assuming you've added the tag for bootstrap.min.js (or whatever flavor you prefer) and jquery`。如果没有,请这样做。

<div class="container menu_bg">
    <div class="row">
        <div class="col-lg-12">
            <ul class="nav nav-tabs">
                <li role="presentation" class="active"><a href="#">Home</a></li>
                <li role="presentation"><a href="#">SVN</a></li>
                <li role="presentation"><a href="#">iOS</a></li>
                <li role="presentation"><a href="#">VB.Net</a></li>
                <li role="presentation" class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-expanded="false">Java<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">Swing</a></li>
                        <li><a href="#">jMeter</a></li>
                        <li><a href="#">EJB</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Separated link</a></li>
                    </ul>
                </li>
                <li><a href="#">PHP</a></li>
            </ul>
        </div>
    </div>
</div>