bootstrap-3对齐div底部的链接和按钮

brg*_*brg 9 css twitter-bootstrap bootstrap-sass twitter-bootstrap-3

从下面的屏幕截图中可以看出,链接未在div的底部对齐.如何对齐按钮编辑,删除,添加购物车 在底部DIV.注意我没有使用表格.

.bottomaligned {position:absolute; bottom:0;  margin-bottom:7px; margin:7px;}
.fixedheight { height: 208px; position:relative; border:1px solid; margin:7px;}
Run Code Online (Sandbox Code Playgroud)

下面显示了模板的相关位,用于呈现屏幕截图如下所示的页面.请注意,使用css class ="bottomaligned"仍然没有对齐链接.即使我添加 宽度:300px; 到了css类.fixedheight,它们仍然没有对齐.

 <div class="row">

  <% @products.each do |product| %>


 <div class="col-lg-3 col-sm-4 col-6 fixedheight ">

    <div class="bottomaligned">
     <%= link_to 'edit', edit_product_path(product), class: "btn btn-danger"  %>

     <%= button_to "Delete", product, data: {confirm: 'Are u sure?'}, method: :delete, class: "btn btn-danger" %>

     <%= button_to "Add to cart", order_items_path(product_id: product) %>

    </div>
    <hr>

  </div><!-- /.col-lg-3 -->

 <% end %>
</div><!-- /.row -->
Run Code Online (Sandbox Code Playgroud)

截图:在此输入图像描述

brg*_*brg 20

我解决了 查看新屏幕截图.我做到了通过添加3个不同的CSS类:bottomaligned,bottomrightBOTTOMLEFT,等各个环节现在有一个不同的CSS类.

  .bottomaligned {position:absolute; bottom:0;  margin-bottom:7px; left: 0;}
  .bottomright {position:absolute; bottom:0;  margin-bottom:7px; margin:7px; right: 0;}
  .bottomleft {position:absolute; bottom:0;  margin-bottom:7px; left: 100px;}
  .fixedheight { height: 200px;  width: 243px;  position:relative; border:1px solid;}
Run Code Online (Sandbox Code Playgroud)

这就是模板现在的样子:

  <div class="col-lg-3 col-sm-4 col-6 fixedheight ">

  <div>
    <div >
      <span class="bottomleft"><%= link_to 'edit', edit_product_path(product), class: "btn btn-danger"  %></span>

      <span class="bottomright"><%= button_to "Delete", product, data: {confirm: 'Are u sure?'}, method: :delete, class: "btn btn-danger" %></span>

      <span class="bottomaligned"> <%= button_to "Add to cart", order_items_path(product_id: product) %></span>

     </div>
    <hr>
  </div><!-- /.col-lg-3 -->
Run Code Online (Sandbox Code Playgroud)

新截图:

在此输入图像描述