這是不是一個真正的乾淨的解決方案,但它不使用JS和每一個瀏覽器我的作品經過測試。
我的解決方案在於將單元格的內容包裝在table-layout: fixed
和width: 100%
的表格中。
查看demo。
下面是完整的解決方案:
<table class="main-table">
<tr>
<td class="nowrap">Button 1</td>
<td>
<table class="fixed-table">
<tr>
<td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus doloremque magni illo reprehenderit consequuntur quia dicta labore veniam distinctio quod iure vitae porro nesciunt. Minus ipsam facilis! Velit sapiente numquam.</td>
</tr>
</table>
</td>
<td class="nowrap">Button 2</td>
</tr>
</table>
.main-table {
width: 100%;
}
.fixed-table {
/* magic */
width: 100%;
table-layout: fixed;
/*not really necessary, removes extra white space */
border-collapse: collapse;
border-spacing: 0;
border: 0;
}
.fixed-table td {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.nowrap {
/* used to keep buttons' text in a single line,
* remove this class to allow natural line-breaking.
*/
white-space: nowrap;
}
這不是真的清楚什麼是對側鍵的意圖,所以我用white-space: nowrap
,讓他們在同一線。根據使用情況,您可能更願意應用min-width
並自然讓他們換行。
如果你發佈你已經嘗試過的東西,這會有所幫助嗎?至少有一些基地,我們可以複製粘貼和修改;) – TweeZz 2013-02-12 06:54:35
我只試過一個表格,一行三個單元格... – kraftwer1 2013-02-12 12:07:20
:)我的意思是你試過的CSS,因爲我認爲硬的部分 – TweeZz 2013-02-13 06:06:51