html - 将表头与引导程序 4 上的表内容对齐
问题描述
我想知道一种将表头与表内容对齐的方法
如您所见,它们没有对齐。我需要在没有固定宽度的情况下对齐列。
标题栏应该占据所有剩余的宽度。
这是我的实际代码:
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr class="d-flex">
<th scope="col" class="col-auto"><i class="fas fa-folder fa-lg"></i></th>
<th scope="col" class="col">Title</th>
<th scope="col" class="col-auto">Author</th>
<th scope="col" class="col-auto">NB</th>
<th scope="col" class="col-auto">Last activity</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td scope="row"><a href=""><i class="fas fa-folder fa-lg"></i></a></td>
<td class="col"><a href="">flap flap flap</a></td>
<td><a href="">Dushy</a></td>
<td>14</td>
<td>03:20:32</td>
</tr>
</tbody>
</table>
</div>
谢谢你的帮助!
解决方案
这是因为你使用col-auto
类。col-auto
用类替换col
类。
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr class="d-flex">
<th scope="col" class="col-auto"><i class="fas fa-folder fa-lg"></i></th>
<th scope="col" class="col">Title</th>
<th scope="col" class="col">Author</th>
<th scope="col" class="col">NB</th>
<th scope="col" class="col">Last activity</th>
</tr>
</thead>
<tbody>
<tr class="d-flex">
<td scope="col" class="col-auto"><a href=""><i class="fas fa-folder fa-lg"></i></a></td>
<td scope="col" class="col"><a href="">flap flap flap</a></td>
<td scope="col" class="col"><a href="">Dushy</a></td>
<td scope="col" class="col">14</td>
<td scope="col" class="col">03:20:32</td>
</tr>
</tbody>
</table>
</div>
推荐阅读
- html - 将图像与文本块对齐
- material-ui - 如何在未连接到互联网的机器上离线使用 material-ui
- php - 当用户从其他设备/位置登录时向用户发送通知
- android - Android 主题并不完全适用于设备
- macros - 如何将变量传递给用于访问系统verilog中路径的define宏
- node.js - (节点:63208)DeprecationWarning:collection.ensureIndex 已弃用。改用 createIndexes
- angular - 在Angular 5中通过blob下载时设置文件名
- crm - 在 windows 2016 服务器上安装 CRM 2015
- python - 在 Python 中更改不可变字符串
- playframework - 如何在 playframework 中使用带有 scalatags 的反向路由?