简体   繁体   中英

ruby on rails tutorial chapter five - styling

I'm running through Michael Hartl's tutorial, and having reached the styling and layout chapter, seem to have got something wrong. Whereas in the tutorial, the site links are right aligned on a single line (like this http://railstutorial.org/images/figures/site_with_footer_bootstrap_4_0-full.png ), I get them right aligned one beneath the other, and some (but not all) other styling elements missing.

I've tried updating gems.

Example code - _header.html.erb

<header class="navbar navbar-fixed-top navbar-inverse">
  <div class="navbar-inner">
<div class="container">
  <%= link_to "sample app", '#', id: "logo" %>
  <nav>
    <ul class="nav pull-right">
      <li><%= link_to "Home",    '#' %></li>
      <li><%= link_to "Help",    '#' %></li>
      <li><%= link_to "Sign in", '#' %></li>
    </ul>
  </nav>
</div>

I think this means that bootstrap is unhappy with something, but I can't tell what.

Thanks for reading this far :)

Assuming that's all of your HTML for the navbar, it doesn't look like the tags were closed properly. Try:

<header class="navbar navbar-fixed-top navbar-inverse">
  <div class="navbar-inner">
    <div class="container">
      <%= link_to "sample app", '#', id: "logo" %>
      <nav>
        <ul class="nav pull-right">
          <li><%= link_to "Home",    '#' %></li>
          <li><%= link_to "Help",    '#' %></li>
          <li><%= link_to "Sign in", '#' %></li>
        </ul>
      </nav>
    </div>
  </div>
</header>

If you ever have questions regarding your code vs what it should be, try checking his repository first.

https://github.com/railstutorial/sample_app_rails_4

There he has a full working copy of the sample application.

Digging further into RADan's comment

Weirdly, gem list --local gives - bootstrap-sass (3.1.1.0, 2.3.2.0)

I found that I had the same problem. To solve this (it serves the newer version of bootstrap instead of the older version - which causes CSS class issues) I deleted the older version of bootstrap by entering the following into the terminal:

gem uninstall bootstrap-sass -v 3.1.1.0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM