将CSS添加到rails表循环中的每个单独元素

时间:2014-06-24 18:02:22

标签: css ruby-on-rails

我在rails中有以下表格

<%= link_to 'New Voice', new_voice_path, class: "btn btn-danger btn-lg" %>
<table>
  <tbody>
    <% @voices.each do |voice| %>
        <tr class = "opinion-list">
          <td id = "opinion"><%= voice.opinion %></td>
          <td><%= link_to 'Show', voice, class: "crud" %></td>
          <td><%= link_to 'Edit', edit_voice_path(voice), class: "crud" %></td>
          <td><%= link_to 'Destroy', voice, method: :delete, data: { confirm: 'Are you sure?' }, class: "crud" %></td>
        </tr>
    <% end %>
  </tbody>
</table>

并输出此屏幕http://imgur.com/RBpOb2G

如何为每个声音添加CSS类,以便每个人的“声音”都有余量?现在它看起来太拥挤,读起来像一个巨大的段落,所以我想在它们之间留一些间距。

我尝试在观点列表中添加保证金/填充,但这不起作用。

我也尝试过像这样使用content_tag

<%= link_to 'New Voice', new_voice_path, class: "btn btn-danger btn-lg" %>
<table>
  <tbody>
    <% @voices.each do |voice| %>
      <%= content_tag(:div, class: "box") do%>
        <tr class = "opinion-list">
          <td id = "opinion"><%= voice.opinion %></td>
          <td><%= link_to 'Show', voice, class: "crud" %></td>
          <td><%= link_to 'Edit', edit_voice_path(voice), class: "crud" %></td>
          <td><%= link_to 'Destroy', voice, method: :delete, data: { confirm: 'Are you sure?' }, class: "crud" %></td>
        </tr>
      <%end%>
    <% end %>
  </tbody>
</table>

和.box类的样式,但也不起作用。

0 个答案:

没有答案