0

这可能很容易解决,但我不明白。

我的下拉菜单不起作用。我只是复制并粘贴文档的代码。而且,如何使用“鼠标悬停”更改菜单工作?谢谢

JSFiddle

  <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="#">Brand</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>
  <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><a href="#">Separated link</a></li>
      <li><a href="#">One more separated link</a></li>
    </ul>
  </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><a href="#">Separated link</a></li>
    </ul>
  </li>
</ul>
</div><!-- /.navbar-collapse -->
 </nav>
4

2 回答 2

2

下次使用 Bootply:http : //bootply.com/80635 这是为 Bootstrap 构建的 jsfiddle。

于 2013-09-12T19:09:06.280 回答
0

仅 HTML 是不够的。您只包含了bootstrap.css文件,但下拉组件至少需要dropdown.js工作。在你的小提琴中,我包含了bootstrapcdn的整个bootstrap.js文件

示例:http: //jsfiddle.net/CurMZ/1/

于 2013-09-12T19:02:19.947 回答