首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在html中最小化表格中的列宽?

如何在html中最小化表格中的列宽?
EN

Stack Overflow用户
提问于 2018-07-17 02:10:45
回答 1查看 479关注 0票数 1

我有一张这样的桌子

但是我希望options列像这样小

代码(使用bootstrap 4的即时通信):

代码语言:javascript
复制
<table class="table table-bordered table-hover">
                        <thead class="table-primary">
                            <tr class="text-center">
                                <th scope="col">#</th>
                                <th scope="col">Nom</th>
                                <th scope="col" colspan="2">Options</th>
                            </tr>
                            </thead>
                        <tbody class="table-light">
                        <tr class="text-center">    
                                <th scope="row"><?php echo $donnees[0]; ?></th>
                                <td><?php echo $donnees[1]; ?></td>
                                <td><a href="#"><img src="res\images\edit-icon.svg" height="30x" title="modifier"></a></td>
                                <td><a href="#"><img src="res\images\delete-icon.svg" height="30x" title="supprimer"></a></td>
                            </tr>
                            </tbody>
                    </table>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-17 02:35:36

一个非常简单的解决方案是将options头的width设置为1%。宽度将为1%,如果内容较大,则为内容的大小。如下所示:

代码语言:javascript
复制
<table class="table table-bordered table-hover">
                    <thead class="table-primary">
                        <tr class="text-center">
                            <th scope="col">#</th>
                            <th scope="col">Nom</th>
                            <th scope="col" colspan="2" width="1%">Options</th>
                        </tr>
                        </thead>
                    <tbody class="table-light">
                    <tr class="text-center">    
                            <th scope="row"><?php echo $donnees[0]; ?></th>
                            <td><?php echo $donnees[1]; ?></td>
                            <td><a href="#"><img src="res\images\edit-icon.svg" height="30x" title="modifier"></a></td>
                            <td><a href="#"><img src="res\images\delete-icon.svg" height="30x" title="supprimer"></a></td>
                        </tr>
                        </tbody>
                </table>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51367808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档