这是不是一个真正的干净的解决方案,但它不使用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