-1

我无法使用 twitter bootstrap 在导航栏中使用下拉菜单,我有:

<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container-fluid">
      <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </a>     
      <div class="nav-collapse collapse">
        <ul class="nav">
          <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 class="divider"></li>
              <li><a href="#">Separated link</a></li>
            </ul>
          </li>
        </ul>
      </div><!--/.nav-collapse -->
    </div><!--/.container-fluid -->
  </div><!--/.navbar-inner -->
</div><!--/.navbar -->

并且头部中包含的javascript如下:

<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
    <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
    <link href="/assets/custom.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
    <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-transition.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-affix.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-alert.js?body=1" type="text/javascript"></script> 
    <script src="/assets/bootstrap-button.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-carousel.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-collapse.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-dropdown.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-modal.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-scrollspy.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-tab.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-tooltip.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-popover.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap-typeahead.js?body=1" type="text/javascript"></script>
    <script src="/assets/bootstrap.js?body=1" type="text/javascript"></script>
    <script src="/assets/application.js?body=1" type="text/javascript"></script>
    ...

所以 jquery 被包含在 bootstrap.js 之前,我缺少什么?我做错了什么?

编辑:我已经清理了我的 application.js,所以现在头部看起来像这样:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
    <link href="/assets/custom.css?body=1" media="all" rel="stylesheet" type="text/css" />
    <script src="/assets/application.js?body=1" type="text/javascript"></script>
...

现在出现了一个向上的白色三角形,以前没有出现过,但没有出现在整个下拉列表中......

在此处输入图像描述

4

2 回答 2

1
  1. 在隔离环境中检查您的标记:http: //jsfiddle.net/handtrix/9992A/(看起来不错)

  2. 也许您应该在页面底部包含 Javascript 文件。

  3. 你用了脚手架($ rails g controller ...)吗?如果是,请记住 rails 脚手架生成器通常会添加 css 文件,这些文件会破坏您的引导 css。尝试删除它们。

  4. 清除浏览器缓存

于 2013-02-14T23:20:43.490 回答
0

问题原来是我在布局中使用的一些 twitter 引导模式,如下所示:

<div class="modal fade" id="modal_terms">

而不是我改为:

<div class="modal hide" id="modal_terms">

现在一切正常,我希望这对其他人有帮助

于 2013-04-29T23:05:47.920 回答