html - 如何独立于引导表同一行中的其他单元格更改一个单元格的高度?
问题描述
我只知道 CSS 的基础知识,所以不知道如何去做。我有一个主要包含 1 行数据的表格,但我的第一行中的最后一个单元格,称为“其他”,有多行
有没有办法使表格中每个单元格的高度变小,除了一个单元格?现在,因为多行的列太大了,所以其余的单元格在数据上方和下方都有额外的空白(见第一个屏幕截图)。当我更改它line-height
时,td
它使整个表格看起来不错,除了一个包含多行的单元格(参见第二个屏幕截图)
html (我省略了一些td
' 以使其看起来更干净):
<table class="table">
<thead>
<tr>
<th scope="col">Something</th>
<th scope="col">Code Version</th>
<th scope="col">Region</th>
<th scope="col">Something</th>
<th scope="col">Something</th>
<th scope="col">Something->Membership</th>
<th scope="col">SBMO</th>
<th scope="col">Something</th>
<th scope="col">IVR</th>
<th scope="col">CPM Something</th>
<th scope="col">Other</th>
</tr>
</thead>
<tbody>
<!-- start loop for mongodb collection: environments-->
<% environments.forEach(function(environment){ %>
<tr>
<td>
<%= environment.something %>
</td>
<td>
<%= environment.codeVersion %>
</td>
<td>
<%= environment.region %>
</td>
<!-- other td's go here --->
<!-- CELL WITH MULTIPLE LINES: -->
<td class="other">
<%= environment.other %>
</td>
<%}); %> <!-- end loop for environments -->
</tr>
</tbody>
</table>
CSS:
.table td {
padding: 0 !important;
margin: 0 !important;
vertical-align: middle;
border-right: 1px solid #d4d4d4;
}
other {
white-space: pre-wrap;
}
解决方案
Rowspan 可能也不会做你想做的事。但是,有一个替代方案,但它不是pretty
。
将内容包装在 div 中,设置其高度并设置overflow:scroll
。这将为内容提供一个滚动条,用户可以上下滚动。
下面只是一个示例,因此您可能希望使用高度来显示您想要的高度。
<style>
.other{
height:50px;
overflow:scroll
}
</style>
<td>
<div class="other">
content goes here.
</div>
推荐阅读
- graphql - Angular Apollo GraphQL Devtools 选项卡不可见
- node.js - 用于带有帆的 react-redux 应用程序的 SSR
- mysql - 错误 1140 (42000) 在没有 GROUP BY 的聚合查询中,表达式 #1
- javascript - 更改/添加 SVG 矩阵
- c# - 显示来自 linq 查询的数据的问题
- data-visualization - 如何在 Oracle 可视化云中更改语言?
- dart - Flutter 布局问题(ListView 和 GridView)
- python - pandas to_csv 将 str 列转换为 int(或 float)
- javascript - gmail如何在没有监听器的情况下捕获鼠标事件?
- android - 即时运行不适用于 android studio 3.3 更新