【发布时间】:2015-01-27 11:54:06
【问题描述】:
我正在使用带有 Rails 4 的 Bootstrap。我正在使用 each_slice() 创建两列。但是,使用以下代码,我在左侧列上得到一个空的大空间。
<% @projects.each_slice(1) do |projects| %>
<div class="col-md-6">
<% projects.each do |project| %>
<p><%= project.name %></p>
<% end %>
</div>
<% end %>
所以为了进一步解释,我得到以下html:
<div class="row">
<div class="col-md-6">This is displayed on the left</div>
<div class="col-md-6">This is displayed on the right</div>
<div class="col-md-6">This is displayed on the right</div>
<!-- Here there is a huge empty space, between the first and fourth div -->
<div class="col-md-6">This is displayed on the left</div>
<div class="col-md-6">This is displayed on the right</div>
<div class="col-md-6">This is displayed on the left</div>
<div class="col-md-6">This is displayed on the right</div>
<div class="col-md-6">This is displayed on the left</div>
</div>
div 的长度不同。我怎样才能均匀地显示它们,而有时 div 之间不会有很大的空间?我检查了所有的填充和边距,这不是因为它们。
【问题讨论】:
-
它们是带有文本对齐的内联块元素吗:在父行上对齐?
-
div 只是块,来自 Bootstrap 的父 .row 只有左右边距。没有文本对齐:对齐...
标签: html css ruby-on-rails twitter-bootstrap ruby-on-rails-4