2 回答

TA貢獻(xiàn)1836條經(jīng)驗(yàn) 獲得超4個贊
Rowspan 可能也不會滿足您的要求。不過,還有一個替代方案,但它不是pretty。
將內(nèi)容包裹在 div 中,設(shè)置其高度并設(shè)置 overflow:scroll。這將為內(nèi)容提供一個滾動條,用戶可以上下滾動。
下面只是一個示例,因此您可能需要調(diào)整高度以顯示您想要的方式。
<style>
.other{
height:50px;
overflow:scroll
}
</style>
<td>
<div class="other">
content goes here.
</div>

TA貢獻(xiàn)2003條經(jīng)驗(yàn) 獲得超2個贊
您還可以截?cái)辔谋荆ú⑻砑邮÷蕴枺┮员砻鲀?nèi)容比顯示的內(nèi)容更多。
添加的簡單好處是,如果您向單元格添加 title 屬性,則單元格的完整內(nèi)容可以顯示為類似于 tooltip
請參閱下面的演示:
table {
box-sizing: border-box;
border-collapse: collapse;
max-width: 800px;
}
table td,
table th {
vertical-align: middle;
border: 1px solid #d4d4d4;
width: 100px;
max-width: 300px;
}
td.other {
overflow: hidden;
max-width: 300px;
text-overflow: ellipsis;
white-space: nowrap;
}
<h2>sample</h2>
<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-->
<tr>
<td>
something
</td>
<td>
version
</td>
<td>
region
</td>
<!-- other td's go here --->
<!-- CELL WITH MULTIPLE LINES: -->
<td class="other" title="other (multi-line) - this is a very long line that should not wrap around the td">
other (multi-line) - this is a very long line that should not wrap around the td
</td>
<!-- end loop for environments -->
</tr>
</tbody>
</table>
- 2 回答
- 0 關(guān)注
- 180 瀏覽
添加回答
舉報(bào)