Bootstrap 2列布局 - 不均匀的帖子大小修复

时间:2017-06-16 07:10:10

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

我在rails上使用ruby创建了一个应用程序并使用了bootstrap,我使用的是2列布局,问题是帖子大小不平等,随后出现了一个尴尬的空白,我想摆脱它。

我的索引页目前是什么样的:Current Index Page 我希望我的索引页面如下所示:Desired Index Page

我的index.html.erb

   <div class="container">
      <% @posts.each_slice(2) do |posts| %>
        <div class="posts-wrapper row">
           <% posts.each do |post| %>
             <div class="col-lg-4 col-md-offset-1">
                <%= post.body %>
             </div> 
           <% end %>
        </div> 
      <% end %>
   </div>

2 个答案:

答案 0 :(得分:0)

.row移出循环,它将被修复

或尝试以下代码,这也应该有效

<div class="container">
  <div class="posts-wrapper row">
    <% @posts.each do |post| %>
      <div class="col-lg-6">
        <%= post.body %>
      </div> 
    <% end %>
  </div> 
</div>

答案 1 :(得分:0)