【问题标题】:Bootstrap + Rails,Items stacking on one single column instead of spreading across rowBootstrap + Rails,项目堆叠在一列而不是跨行分布
【发布时间】:2017-12-18 11:46:12
【问题描述】:

我正在学习 Rails 教程,我的项目堆叠在一列上,而不是分散在一行中

    <div class ="row">
  <% @listings.each do |listing| %>
  <div class="col-md-3">
    <%= image_tag listing.image.url(:thumb)%><br>
    <%= listing.name %><br>
    <%= listing.description %><br>
    <%= listing.price %><br>
    <%= link_to 'Show', listing, class: "btn btn-link" %><br>
    <%= link_to 'Edit', edit_listing_path(listing), class: "btn btn-link" %><br>
    <%= link_to 'Destroy', listing, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-link" %>
  <div>
    <% end %>
    </div>

【问题讨论】:

  • 如果这是您要测试的确切代码,那么您有错字。 &lt;div class="col-md-3"&gt; 的结束标签写成 &lt;div&gt; 但应该是 &lt;/div&gt;
  • 确认一下,即使您的浏览器展开/全屏,它们是否堆叠在一列中?

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


【解决方案1】:

它会,您必须在列达到 12 后创建一个新行。根据您的代码,这将需要 4 轮。快速的方法是使用计数器。

【讨论】:

猜你喜欢
  • 2015-05-16
  • 1970-01-01
  • 2018-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-26
  • 2021-12-14
相关资源
最近更新 更多