最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - Bootstrap 5 - text-end class is not properly aligned - Stack Overflow

programmeradmin1浏览0评论

I'm having an issue in properly setting my text-align to the right using Bootstrap 5. After some investigating I thought by adding class=text-end from this question would help me move the total to the very end of my table, but as you can see from the pic below that is not the case. Why is this happening and how can I fix this?

<div class="row">
    <table class="table table-striped">
        <thead>
            <tr>
                <th scope="col">Product</th>
                <th scope="col">Quantity</th>
                <th scope="col">Unit Price</th>
            </tr>
        </thead>
        <tbody>
            @foreach(var order in @Model.OrderDetails)
            {
                <tr>
                    <td>@order.Product.ProductName</td>
                    <td>@order.Quantity</td>
                    <td>[email protected]/ea</td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr class="text-end">
                <th>Total :</th>
                <td>[email protected]</td>
            </tr>
        </tfoot>
    </table>
</div>

I'm having an issue in properly setting my text-align to the right using Bootstrap 5. After some investigating I thought by adding class=text-end from this question would help me move the total to the very end of my table, but as you can see from the pic below that is not the case. Why is this happening and how can I fix this?

<div class="row">
    <table class="table table-striped">
        <thead>
            <tr>
                <th scope="col">Product</th>
                <th scope="col">Quantity</th>
                <th scope="col">Unit Price</th>
            </tr>
        </thead>
        <tbody>
            @foreach(var order in @Model.OrderDetails)
            {
                <tr>
                    <td>@order.Product.ProductName</td>
                    <td>@order.Quantity</td>
                    <td>[email protected]/ea</td>
                </tr>
            }
        </tbody>
        <tfoot>
            <tr class="text-end">
                <th>Total :</th>
                <td>[email protected]</td>
            </tr>
        </tfoot>
    </table>
</div>

Share Improve this question edited Feb 8 at 0:51 Yong Shun 51.2k6 gold badges35 silver badges63 bronze badges asked Feb 7 at 22:10 DonDavid12DonDavid12 1977 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

You should specify the Total header column to use 2 columns via colspan="2" in the footer.

<tr class="text-end">
  <th colspan="2">Total :</th>
  <td class="text-end">[email protected]</td>
</tr>

Demo @ StackBlitz

发布评论

评论列表(0)

  1. 暂无评论