css - 表中的列未正确对齐
问题描述
我有这个带有引导程序样式的html。我的问题是里面的行thead
与里面的行不对齐tbody
(请参阅 jsfiddle 链接以查看正在发生的事情的示例):
<table class="table">
<thead>
<tr id="table-header">
<th scope="col">#</th>
<th class="search" scope="col">nome</th>
<th scope="col">
</th>
</tr>
</thead>
<tbody id="table-body" style="display: block;" data-json="/categoria/list.json">
<tr>
<th scope="row">1</th>
<td>hum</td>
<td>
<div class="btn-group" id="buttons" role="group" aria-label="comandos">
<button sec:authorize="hasPermission(#user, 'atualiza_categoria')" type="button" class="btn btn-secondary" id="update" th:attr="data-url=@{/categoria/update}" onclick="open_tab(this)">
edit
</button>
<button sec:authorize="hasPermission(#user, 'remove_categoria')" type="button" class="btn btn-secondary" id="delete" th:attr="data-url=@{/categoria/delete}" onclick="open_tab(this)">
del
</button>
</div>
</td>
</tr>
</tbody>
<tbody id="table-search" style="display: none;" data-json="/categoria/search.json"></tbody>
</table>
此代码基于此处提供的第一个示例:https ://getbootstrap.com/docs/4.4/content/tables/ 。我尝试更改线路:
<th scope="row">1</th>
内部tbody
:
<td scope="row">1</td>
但同样的问题发生。
jsfiddle:https ://jsfiddle.net/klebermo/0gdtf7qy/
任何人都可以告诉如何解决这个问题?
解决方案
你不能使用tbody
display: block;
. tbody
display
财产将table-row-group
。
所以style="display: block;"
从tbody
标签中删除。检查here工作示例
推荐阅读
- powershell - 复制具有特定父目录的所有文件,同时维护目录树
- mysql - MySQL LIKE 与 json_extract
- excel - vba 数据类型问题 - 如何正确插入数字(带逗号)?
- java - 如何修复错误“最后一个成功发送到服务器的数据包是 0 毫秒前。驱动程序没有收到来自服务器的任何数据包”
- node.js - Node Js 运行构建错误无法解析组件
- python - Chua的电路使用python和绘图
- swift - 如何在 Swift 中更改 SF Symbols 图标的颜色?
- javascript - ipc Renderer 说它不是一个功能,即使我认为我使用正确
- html - CSS 中的一些响应式问题
- django - 使用 Django Rest Framework 实现 MVC 模式