html - 如何将列固定在 html 表中并且仅相对于一列?
问题描述
我有一个 7 列的 html 表。为什么宽度是相对的而不是固定的。如果我给类属性: style="table-layout: fixed; width: 100%;" ...然后所有列具有相同的宽度...
我该怎么做才能使列获得正确的宽度?
- labelD => 宽度:80px;
- 标签N => 宽度:50px;
- 和 labelT => 宽度:100%;桌子的其余部分...
.label {
padding-top: 5px;
text-align: right;
vertical-align: top;
}
.labelD {
width: 80px;
}
.labelN {
width: 50px;
}
.labelT {
width: calc(100% - 330px);
}
.list {
border: hidden 1px #e8eef4;
border-collapse: collapse;
width: 100%;
}
<div>
<table class="list">
<tr>
<th class="label labelD">Date</th>
<th class="label labelN">Note1</th>
<th class="label labelN">Note2</th>
<th class="label labelT">Title</th>
<th class="label labelN">Note3</th>
<th class="label labelN">Note4</th>
<th class="label labelN">Note5</th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
解决方案
Try:
.labelT { width: calc(100% - 330px); }
Every column will need a width though.
推荐阅读
- python - Python URLencode问题
- c# - 控制台不处理转义序列
- java - Android studio 条码读取
- amazon-web-services - 为 AWS Systems Manager 设置 SSL 以与 EC2 一起使用
- windows - 批量查找和替换括号之间的文本
- shell - 我的命令行/终端上的 [SIGINT] 是什么意思?
- php - Symfony:如何获取与 oneToMany 关系相关的所有用户帖子
- javascript - javascript 代码错误:未捕获的 ReferenceError:**** 未在 HTMLDivElement.onclick 中定义
- angular - 如何在 Angular 中通过 Angular Material 使用浏览器的表单数据值
- android - 在反应本机后台下载器中更改并发限制