开发者

How to set the max number of text rows (wraps) in a td?

开发者 https://www.devze.com 2023-03-26 09:58 出处:网络
<table border=\"3\"> <tr> <td class=\"table_class\">111111 222222 333333 </td> <td class=\"table_class\">234 </td> </tr开发者_开发知识库>
<table border="3">
        <tr> <td class="table_class">111111 222222 333333 </td> <td class="table_class">234 </td> </tr开发者_开发知识库>
        <tr> <td class="table_class">2321</td> <td class="table_class">ssS</td> </tr>
    </table>

.table_class {
    width: 20px;
}

Live example: http://jsfiddle.net/Nzd9K/

How can I "capture" numbers of rows in TD? For example,I would like max two rows in TD. I can use substr, but this isn't good idea. Extra text let be cut off.


You can add a wrapper div with overflow: hidden inside each td.

See: http://jsfiddle.net/Nzd9K/17/

<td class="table_class"><div>111111 222222 333333</div></td>

.table_class div {
    height: 2.5em; /* adjust to taste */
    overflow: hidden
}
0

精彩评论

暂无评论...
验证码 换一张
取 消