Bootstrap下拉列表充当块级元素

时间:2018-04-16 04:21:33

标签: jquery twitter-bootstrap css3 twitter-bootstrap-3

下拉列表转到新行,下拉列表不会崩溃。它将自己显示为列表。是否存在Java脚本问题。

我正在使用bootstrap v3.3.4和jquery v2.1.2。我在bootstrap.min.js之前放置了Jquery脚本。

<!DOCTYPE html>
<html>

  <head>
    <title>Shaunta's Botique</title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <meta name="viewport" content="width=device-width, initial scale=1, user-scalable=" no ">
    <script src="https://code.jquery.com/jquery-2.1.2.min.js "
            integrity="sha256-YE7BKn1ea9jirCHPr/EaW5NxmkZZGb52+ZaD2UKodXY="
            crossorigin=" anonymous "></script>
    <script src="js/bootstrap.min.js "></script>
    <script src="js/tether.min.js "></script>

</head>
<body>
    <!-- Top Nav Bar -->
    <nav class="navbar navbar-default navbar-fixed-top ">
        <div class="container ">
            <a class="navbar-brand " href="index.php ">Shaunta's Botuqie</a></div>
            <ul class="nav navbar-nav ">
                <li class="dropdown ">
                    <a href="# " class="dropdown-toggle " data-toggle="dropdown ">Men <span class="caret "></span></a>
                    <ul class="dopdown-menu " role="menu ">
                        <li><a href=" ">Shirts</a></li>
                        <li><a href=" ">Pants</a></li>
                        <li><a href=" ">Shoes</a></li>
                        <li><a href=" ">Accessories</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>

    <!-- Header -->
    <div id="header-wrapper ">

    </div>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

你的代码中有一些拼写错误。班级应为dropdown-menu

<ul class="dopdown-menu " role="menu ">

还缺少aria-expandedaria-labelledby等一些属性。我已经使用bootstrap documentation按参考添加了这些属性。

所以最终的标记看起来像 -

  <nav class="navbar navbar-default navbar-fixed-top ">
    <div class="container ">
      <a class="navbar-brand" href="index.php ">Shaunta's Botuqie</a></div>
      <ul class="nav navbar-nav">
        <li class="dropdown">
          <a class=" dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
            Men
            <span class="caret"></span>
          </a>
          <ul class="dropdown-menu " role="menu " aria-labelledby="dropdownMenu1">
            <li><a href=" ">Shirts</a></li>
            <li><a href=" ">Pants</a></li>
            <li><a href=" ">Shoes</a></li>
            <li><a href=" ">Accessories</a></li>
          </ul>
        </li>
      </ul>
    </div>
  </nav>

请参阅此工作fiddle