简体   繁体   English

Ruby on Rails教程第五章-样式

[英]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. 我正在遍历Michael Hartl的教程,并且到达了“样式和布局”一章,似乎有问题。 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. 而在本教程中,站点链接在一行上右对齐(例如http://railstutorial.org/images/figures/site_with_footer_bootstrap_4_0-full.png ),但我却将它们正确地对齐在另一行的下方,有些( (但不是全部)缺少其他样式元素。

I've tried updating gems. 我试过更新宝石。

Example code - _header.html.erb 示例代码-_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. 假设这是导航栏的全部HTML,看起来标记未正确关闭。 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 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 进一步探讨RADan的评论

Weirdly, gem list --local gives - bootstrap-sass (3.1.1.0, 2.3.2.0) 奇怪的是,gem list --local给出了-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: 为了解决这个问题(它提供了较新版本的引导程序,而不是较旧版本的引导程序,这会导致CSS类问题),我通过在终端中输入以下内容来删除了较旧版本的引导程序:

gem uninstall bootstrap-sass -v 3.1.1.0 gem卸载bootstrap-sass -v 3.1.1.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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