以下代碼在chrome上按照需要工作。 但不是在Firefox或IE。將<!DOCTYPE html>
標記添加到此代碼中,導致它不能在chrome上工作。有text-overflow
已被棄用或什麼?我如何使它與所有瀏覽器和HTML5兼容?文本溢出不能與HTML5一起使用
<head>
<style type='text/css'>
table {
display: block;
margin: 30px 0 auto 0;
width: 100%;
max-width: 1300px;
text-align: left;
white-space: nowrap;
border-collapse: collapse;
z-index: -1;
table-layout:fixed;
}
td {
overflow: hidden;
white-space: nowrap;
word-wrap:break-word;
text-overflow:ellipsis;
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<th style="width: 18%;">Col 1</th>
<th style="width: 12%;">Col 2</th>
<th style="width: 13%;">Col 3</th>
<th style="width: 7%">Col 4</th>
<th style="width: 7%">Col 5</th>
<th style="width: 6%">Col 6</th>
<th style="width: 5%">Col 7</th>
<th style="width: 13%">Col 8</th>
<th style="width: 16%">Col 9</th>
<th style="width: 3%">Col 10</th>
</tr>
<tr>
<td>Some</td>
<td>Data</td>
<td>Stuff</td>
<td>foo</td>
<td>bar</td>
<td>etc</td>
<td>whatever</td>
<td>stuff</td>
<td>Alotofdataikkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk</td>
<td>Yes</td>
</tr>
</table>
</body>
這就是我想要的。
這個怎麼樣? http://jsbin.com/okuqan/2/edit – Antony 2013-05-14 07:22:16
看看這裏http://stackoverflow.com/questions/9789723/css-text-overflow-in-a-table-cell – Morpheus 2013-05-14 07:22:26
它支持所有瀏覽器...你可以在這裏查看:http://www.w3schools.com/cssref/css3_pr_text-overflow.asp – 2013-05-14 07:22:47