Bootstrap子菜单无法正常工作

时间:2012-12-12 14:39:45

标签: twitter-bootstrap

子菜单在以下代码中无法正常工作。你能提供解决方案吗?

这是代码, http://jsfiddle.net/4UVt3/1/

同样小提琴复制粘贴在这里,

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">    
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
  </head>
  <body>
  <div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
   <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
      <li><a tabindex="-1" href="#">Action</a></li>
      <li><a tabindex="-1" href="#">Another action</a></li>
      <li><a tabindex="-1" href="#">Something else here</a></li>
      <li class="dropdown-submenu">
        <a tabindex="-1" href="#">More options</a>
        <ui class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ui>
      </li>
    </ul>
  </div>
  </body>
</html>

2 个答案:

答案 0 :(得分:3)

子菜单下拉菜单中有拼写错误。它指定为“ui”而不是“ul”。

将子菜单下拉菜单更改为

<ul class="dropdown-menu">
    <li><a tabindex="-1" href="#">Submenu 1</a></li>
    <li><a tabindex="-1" href="#">Submenu 2 </a></li>
    <li><a tabindex="-1" href="#">Submenu 3 </a></li>
</ul>

答案 1 :(得分:3)

    <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewporta" content="width=device-width, initial-scale=1.0">    
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
    <script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
  </head>
  <body>
  <div class="dropdown">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#">Dropdown trigger</a>
   <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
      <li><a tabindex="-1" href="#">Action</a></li>
      <li><a tabindex="-1" href="#">Another action</a></li>
      <li><a tabindex="-1" href="#">Something else here</a></li>
      <li class="dropdown-submenu">
        <a tabindex="-1" href="#">More options</a>
        <ul class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ul>
      </li>
    </ul>
  </div>
  </body>
</html>

您使用的是ui而不是ul,上面的代码是工作版本,下面是更改。

        <ul class="dropdown-menu">
          <li><a tabindex="-1" href="#">Submenu 1</a></li>
          <li><a tabindex="-1" href="#">Submenu 2 </a></li>
          <li><a tabindex="-1" href="#">Submenu 3 </a></li>
        </ul>