Twitter Bootstrap: navbar button not showing or toggling collapse

Matthew picture Matthew · May 1, 2013 · Viewed 14.3k times · Source

I'm adapting Twitter's Bootstrap to my Ruby on Rails tutorial project (By Michael Hartl) and the upper navigation isn't collapsing.

I'm currently getting this:

enter image description here

My end goal is this:

enter image description here

I've copied and pasted the start_template.html into mine, ensured that all the right bootstrap.css and js files are referenced, and don't know how else to tackle this issue.

My home.html is pasted below (apologies if it's too much code):

<title> Project Name</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet">

    <link href="http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">

  <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" />
<link href="/assets/static_pages.css?body=1" media="all" rel="stylesheet" type="text/css" />

  <meta content="authenticity_token" name="csrf-param" />
<meta content="khAXbodB/h2ghLK1iZlFZIU6RtxF1kv//qsyrJVszlE=" name="csrf-token" />



<div class="navbar navbar-inverse navbar-fixed-top">
  <div class="navbar-inner">
    <div class="container">
      <button type="button" 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>
      </button>

      <a class="brand" href="#">Project Name</a>

      <div class="nav-collapse collapse">
        <ul class="nav">
            <li> <a href="/">Home</a> </li>
            <li><a href="/about">About</a></li>
            <li> <a href="/help">Help</a> </li>
            <li> <a href="#">Sign In</a> </li>
        </ul>
      </div>
    </div>
  </div>
</div>



    <div class="container-fluid">
        <div class="center hero-unit">
<h1>Project Name</h1>
<h2>Subheader and more info</h2>

    <a href="#" class="btn btn-large btn-primary">Sign Up Now!</a>
</div>


        <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-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-popover.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-transition.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/static_pages.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>

</div>

Answer

Zim picture Zim · May 1, 2013

The Bootstrap code seems to work fine.. http://bootply.com/60444

My guess is that something in /assets/custom.css or /assets/application.css is messing up the Bootstrap 'navbar-fixed-top'.

You could try putting 'bootstrap-responsive.css' after those and see if that makes a difference.