右对齐表格页脚

时间:2018-09-04 20:15:44

标签: html css html5 css3

我有一个包含数据的表,我希望第一个页脚项向左对齐,其余的页脚向右对齐。

以下是预期结果:

enter image description here

table {
  width: 100%
}
<table class="price-list">
  <thead>
    <tr>
      <th>No</th>
      <th>Nome</th>
      <th>Quantidade</th>
      <th>Preço</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>text1</td>
      <td>text2</td>
      <td>text3</td>
      <td>text4</td>
    </tr>
  </tbody>
  <tfoot class="footer">
    <tr align="left">
      <td id="cart_voucher" class=" cart_voucher">
        <form action="http://localhost:8080/index.php?controller=order-opc" method="post" id="voucher">
          <div class="form-group form-group-placeholder">
            <input type="text" class="discount_name form-control" id="discount_name" name="discount_name" placeholder="Kod rabatowy" value="">
            <i class="fa fa-angle-right discount_icon" aria-hidden="true"></i>
            <input type="hidden" name="submitDiscount">
          </div>
        </form>
      </td>
    </tr>
    <!-- end VOUCHER -->
    <!-- Total products -->
    <tr align="right">
      <td>Total products </td>
      <td id="total_product">500,00 zł</td>
    </tr>
    <tr align="right">
      <td Total shipping (tax incl.):>
      </td>
      <td id="total_shipping" class="price-opc">12,00 zł</td>
    </tr>
    <tr align="right">
      <td>Total (tax excl.):</td>
      <td id="total_price_without_tax" class="price-opc">418,50 zł</td>
    </tr>
    <!-- end Total tax excl. -->
    <!-- Total tax -->
    <tr align="right">
      <td>Total tax:</td>
      <td>93,50 zł</td>
    </tr>
    <!-- end Total tax -->
    <tr align="right">
      <td>Total:</td>
      <td>
        <span>512,00 zł</span>
      </td>
    </tr>
  </tfoot>
</table>

我将内联align="left"用于第一个页脚元素,并将align="right"用于其余元素。我得到以下信息:

enter image description here

更新更多说明  在页脚中,我们有表单输入和其他数据,应保留表单输入,其余页脚元素应在右侧,如下图所示 enter image description here

我尝试对每个flex-box使用tr,但是没有任何效果。有人可以帮帮我吗?我只希望页脚中的第一个元素向左对齐,其余元素向右对齐。谢谢,任何帮助或建议都会有所帮助。忽略theadtbody,只需考虑tfoot

1 个答案:

答案 0 :(得分:3)

您可以应用float属性,以接受rightleft丝线

.container {
  width: 100%;
  height: 100px;
  background-color: red;
}

.left {
  float: left;
  background-color: yellow;
}

.right {
  float: right;
  background-color: yellow;
}
<div class="container">
  <div class="left">Left Child</div>
  <div class="right">Right Child</div>
</div>

属性是这样工作的

相关问题