HTML中,一個表格,要達到二個條件:
1、內容多了不自動換行;
2、固定單元格寬度。如果內容超出,則隱藏;
如 果在IE下,只是寫成<table style="table-layout:fixed; overflow:hidden;"><tr><td nowrap>則可,而在FF下則不行。兼容IE和FF的寫法,應該為:<table style="table-layout:fixed;"><tr>td style="overflow:hidden;" nowrap>
3、顯示省略標記,只支持IE:
text-overflow:ellipsis;
測試代碼:
<style>.tbl {table-layout:fixed}.td {overflow:hidden;text-overflow:ellipsis}</style>
<table class="tbl" border=1 width=80>
<tr>
<td width=25% class="td" nowrap>abcdefghigklmnopqrstuvwxyz 1234567890</td>
<td class="td" nowrap><div>abcdefghigklmnopqrstuvwxyz 1234567890</div></td>
</tr>
</table>