以下代码在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