【问题标题】:Rails 4 adding BootstrapRails 4 添加引导程序
【发布时间】:2013-07-03 02:00:29
【问题描述】:

我创建了一个 Rails 4 示例应用程序。我添加了 twitter-bootstrap-rails gem 并使用安装程序来设置所有文件:rails generate bootstrap:install less。然后我创建了一个脚手架并迁移了数据库,并且 bootstrap.css 出现了它应该的样子。然后我手动创建了一个没有脚手架的模型/视图/控制器,并且没有在其上使用引导 css。这是我的看法:

<table class="table table-striped">
  <thead>
    <tr>
      <th>Name</th>
      <th>Age</th>
    </tr>
  </thead>
    <tr>
      <td>Jason</td>
      <td>John</td>
    </tr>
  <tbody>

  </tbody>
</table>

我应该有一个条纹表,但它不起作用。有任何想法吗?谢谢。

【问题讨论】:

  • 你用什么浏览器?你能在浏览器上看到 style td(odd) use inspect element tool 吗?如果你能看到.table-striped tbody &gt; tr:nth-child(odd) &gt; td, .table-striped tbody &gt; tr:nth-child(odd) &gt; th { background-color: #f9f9f9; },表示你的显示器无法分辨相邻的颜色
  • 不,在检查器中我没有看到任何 Bootstrap 类。
  • 你确定布局上有调用样式表吗?

标签: css ruby-on-rails twitter-bootstrap twitter-bootstrap-rails


【解决方案1】:

是复制粘贴错误还是您的代码?

请注意,该行不在 tbody 中,您只有一行多于一行,以查看它是否为条纹

【讨论】:

    【解决方案2】:

    如果您的引导类即将到来,请在浏览器中检查,您可以通过在已编译的 css 中搜索任何引导类来做到这一点。如果不存在,请检查资产文件夹中的应用程序 css 文件是否包含引导程序... 还要更正您的标记...

    <table class="table table-striped">
     <thead>
      <tr>
       <th>Name</th>
       <th>Age</th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>Jason</td>
       <td>John</td>
      </tr>
     </tbody>
    </table>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-30
      • 1970-01-01
      • 2018-08-06
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多