首页 > 解决方案 > 为什么 td size 在我的引导表中变得如此之宽?

问题描述

我有一个包含一些元素的引导表:

                <table class="table">
                    <thead>
                        <tr>
                            <h5>Orders from Restaurant</h5>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="pr-0">
                                <img src="../../../storage/images/food/sharshara/appetizer_wing_preview.jpg"
                                    height="100px" class="img-thumbnail">
                            </td>
                            <td>
                                <h4 class="">Chicken wings</h4>
                                <p>No sauce, extra dust</p>
                                <div class="float-right">
                                    <div class="input-group input-group-sm" style="width: 100px">
                                        <div class="input-group-prepend">
                                            <button class="btn btn-danger" type="button" id="button-addon1">
                                                <i class="fa fa-minus" aria-hidden="true"></i>
                                            </button>
                                        </div>
                                        <input type="text" class="form-control text-center" value="1"
                                            aria-describedby="button-addon1">
                                        <div class="input-group-append">
                                            <button class="btn btn-success" type="button" id="button-addon1">
                                                <i class="fa fa-plus" aria-hidden="true"></i>
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>

但是由于某种原因,我的表格列变宽了,​​我尝试在 css 和 td 参数中更改宽度,没有任何帮助。 在此处输入图像描述

标签: bootstrap-4

解决方案


您需要“修复”一些事情..

  • 使用 width:1% 缩小列宽以适合图像
  • 不要使用img-thumbnail,因为那会缩小图像

HTML

   <tbody>
        <tr>
            <td class="pr-0" style="width:1%">
                <img src="..." />
            </td>
            <td>
                ..
            </td>
        </tr>
    </tbody>

https://www.codeply.com/go/epJgrepmYB


推荐阅读