我是 Rails 初学者。 我想制作两个排成一行的按钮。
如何将按钮正确地放在表格的一行上?
两个按钮:
<%= button_to "empty Cart", @cart, method: :delete %>
<%= submit_tag "Delete item" %>
我的观点 <%= form_tag destroy_multiple_carts_path,方法::delete do %>
<table class="table">
<tbody>
<tr>
<td class = "checkbox_size_sm"><input type="checkbox"></td>
<td class = "image">ITEM</td>
<td class = "title"> </td>
<td>PRICE</td>
</tr>
<% @cart.line_items.order(created_at: :desc).each do |item| %>
<tr>
<td><%= check_box_tag "item_ids[]", item.id %></td>
<td class = "image"><%= image_tag item.product.item, size: "100" %>
</td>
<td class = "title" id = "td_align_middle">
<%= item.product.title %><br>
<%= item.product.brand %>
</td>
<td id = "td_align_middle"><%= item.product.price %></td>
</tr>
<% end %>
</tbody>
<tfoot>
<tr>
<td colspan = "4" class="total_price" >
Total Price <strong> <%= @cart.cart_total_price %> </strong>
</td>
</tr>
<tr>
<td colspan ="4" class="al-r">
<%= button_to "empty Cart", @cart, method: :delete %> <%= submit_tag "Delete item" %>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
帮帮我..
最佳答案
将这些按钮包裹在一个 div 中,将 div 设置为向左浮动并 overflow hidden
在带有 divname 类的 div 中添加软管两个按钮,并在 css 文件中添加以下样式
div.divname button { float:left;右边距:10px; }
关于css - rails css 如何将两个按钮排成一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29317894/